mirror of
https://github.com/penpot/penpot.git
synced 2026-11-23 19:00:36 +00:00
🐛 Keep a flow when the context menu of its starting board opens
In Prototype mode, right-clicking a board that starts a flow removed the flow: the "Delete flow start" entry called `do-remove-flow` while rendering instead of on click. React also logged "Cannot update a component while rendering a different component". The entry now removes the flow only when it is clicked. Found by the components Qase run (PENPOT-1771). Test: `context-menu-prototype-test`. AI-assisted-by: claude-opus-5-5
This commit is contained in:
parent
b7ee5d30ec
commit
81ff4c0c90
@ -602,7 +602,7 @@
|
||||
(when (and prototype? is-frame?)
|
||||
(if-let [flow (ctp/get-frame-flow flows (-> shapes first :id))]
|
||||
[:> menu-entry* {:title (tr "workspace.shape.menu.delete-flow-start")
|
||||
:on-click (do-remove-flow flow)}]
|
||||
:on-click #(do-remove-flow flow)}]
|
||||
[:> menu-entry* {:title (tr "workspace.shape.menu.flow-start")
|
||||
:on-click do-add-flow}]))))
|
||||
|
||||
|
||||
@ -187,6 +187,7 @@
|
||||
[frontend-tests.ui.comment-input-ime-test]
|
||||
[frontend-tests.ui.comments-clustering-test]
|
||||
[frontend-tests.ui.comments-position-modifier-test]
|
||||
[frontend-tests.ui.context-menu-prototype-test]
|
||||
[frontend-tests.ui.dashboard-import-linking-test]
|
||||
[frontend-tests.ui.drawarea-test]
|
||||
[frontend-tests.ui.ds-controls-numeric-input-test]
|
||||
@ -443,6 +444,7 @@
|
||||
'frontend-tests.ui.comment-input-ime-test
|
||||
'frontend-tests.ui.comments-clustering-test
|
||||
'frontend-tests.ui.comments-position-modifier-test
|
||||
'frontend-tests.ui.context-menu-prototype-test
|
||||
'frontend-tests.ui.dashboard-import-linking-test
|
||||
'frontend-tests.ui.drawarea-test
|
||||
'frontend-tests.ui.ds-controls-numeric-input-test
|
||||
|
||||
@ -0,0 +1,45 @@
|
||||
;; This Source Code Form is subject to the terms of the Mozilla Public
|
||||
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
;;
|
||||
;; Copyright (c) KALEIDOS SUBSIDIARY SL
|
||||
|
||||
(ns frontend-tests.ui.context-menu-prototype-test
|
||||
(:require
|
||||
["react-dom/server" :as rds]
|
||||
[app.common.uuid :as uuid]
|
||||
[app.main.refs :as refs]
|
||||
[app.main.store :as st]
|
||||
[app.main.ui.workspace.context-menu :as cm]
|
||||
[app.util.i18n :as i18n]
|
||||
[cljs.test :as t :include-macros true]
|
||||
[cuerdas.core :as str]
|
||||
[frontend-tests.helpers.mock :as mock]
|
||||
[okulary.core :as l]
|
||||
[rumext.v2 :as mf]))
|
||||
|
||||
(defn- render-menu
|
||||
"Render the prototype entries for `frame`, returning the markup and the
|
||||
events emitted while rendering."
|
||||
[flows frame]
|
||||
(let [events (atom [])
|
||||
markup (with-redefs [refs/workspace-page-flows (l/atom flows)
|
||||
refs/options-mode-global (l/atom :prototype)
|
||||
st/emit! (mock/stub (fn [& emitted] (swap! events into emitted)))
|
||||
i18n/tr (mock/stub (fn [key] key))]
|
||||
(rds/renderToStaticMarkup
|
||||
(mf/element @#'cm/context-menu-prototype* #js {:shapes [frame]})))]
|
||||
{:markup markup :events @events}))
|
||||
|
||||
(t/deftest a-flow-start-board-menu-offers-removing-the-flow-without-removing-it
|
||||
(let [frame-id (uuid/next)
|
||||
flow-id (uuid/next)
|
||||
flows {flow-id {:id flow-id :name "Flow 1" :starting-frame frame-id}}
|
||||
{:keys [markup events]} (render-menu flows {:id frame-id :type :frame})]
|
||||
(t/is (str/includes? markup "workspace.shape.menu.delete-flow-start"))
|
||||
(t/is (= [] events))))
|
||||
|
||||
(t/deftest a-plain-board-menu-offers-a-flow-start
|
||||
(let [{:keys [markup events]} (render-menu {} {:id (uuid/next) :type :frame})]
|
||||
(t/is (str/includes? markup "workspace.shape.menu.flow-start"))
|
||||
(t/is (= [] events))))
|
||||
Loading…
x
Reference in New Issue
Block a user