mirror of
https://github.com/penpot/penpot.git
synced 2025-06-06 22:51:37 +02:00
🐛 Fix context menu when two elements where selected
This commit is contained in:
parent
1c3470ca53
commit
6fb97e54a9
1 changed files with 13 additions and 15 deletions
|
@ -372,27 +372,25 @@
|
|||
has-frame? (->> shapes (d/seek cph/frame-shape?))
|
||||
is-frame? (and single? has-frame?)
|
||||
is-flex-container? (and is-frame? (= :flex (:layout (first shapes))))
|
||||
has-group? (->> shapes (d/seek cph/group-shape?))
|
||||
is-group? (and single? has-group?)
|
||||
ids (->> shapes (map :id))
|
||||
add-flex #(st/emit! (if is-frame?
|
||||
(dwsl/create-layout-from-id ids :flex)
|
||||
(dwsl/create-layout-from-selection :flex)))
|
||||
remove-flex #(st/emit! (dwsl/remove-layout ids))]
|
||||
(cond
|
||||
(or single? (and is-frame? (not is-flex-container?)) is-group?)
|
||||
[:*
|
||||
[:& menu-separator]
|
||||
[:& menu-entry {:title (tr "workspace.shape.menu.add-flex")
|
||||
:shortcut (sc/get-tooltip :toggle-layout-flex)
|
||||
:on-click add-flex}]]
|
||||
|
||||
is-flex-container?
|
||||
[:*
|
||||
[:& menu-separator]
|
||||
[:& menu-entry {:title (tr "workspace.shape.menu.remove-flex")
|
||||
:shortcut (sc/get-tooltip :toggle-layout-flex)
|
||||
:on-click remove-flex}]])))
|
||||
[:*
|
||||
(when (not is-flex-container?)
|
||||
[:div
|
||||
[:& menu-separator]
|
||||
[:& menu-entry {:title (tr "workspace.shape.menu.add-flex")
|
||||
:shortcut (sc/get-tooltip :toggle-layout-flex)
|
||||
:on-click add-flex}]])
|
||||
(when is-flex-container?
|
||||
[:div
|
||||
[:& menu-separator]
|
||||
[:& menu-entry {:title (tr "workspace.shape.menu.remove-flex")
|
||||
:shortcut (sc/get-tooltip :toggle-layout-flex)
|
||||
:on-click remove-flex}]])]))
|
||||
|
||||
(mf/defc context-menu-component
|
||||
[{:keys [shapes]}]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue