mirror of
https://github.com/penpot/penpot.git
synced 2025-06-09 16:11:38 +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?))
|
has-frame? (->> shapes (d/seek cph/frame-shape?))
|
||||||
is-frame? (and single? has-frame?)
|
is-frame? (and single? has-frame?)
|
||||||
is-flex-container? (and is-frame? (= :flex (:layout (first shapes))))
|
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))
|
ids (->> shapes (map :id))
|
||||||
add-flex #(st/emit! (if is-frame?
|
add-flex #(st/emit! (if is-frame?
|
||||||
(dwsl/create-layout-from-id ids :flex)
|
(dwsl/create-layout-from-id ids :flex)
|
||||||
(dwsl/create-layout-from-selection :flex)))
|
(dwsl/create-layout-from-selection :flex)))
|
||||||
remove-flex #(st/emit! (dwsl/remove-layout ids))]
|
remove-flex #(st/emit! (dwsl/remove-layout ids))]
|
||||||
(cond
|
|
||||||
(or single? (and is-frame? (not is-flex-container?)) is-group?)
|
|
||||||
[:*
|
[:*
|
||||||
|
(when (not is-flex-container?)
|
||||||
|
[:div
|
||||||
[:& menu-separator]
|
[:& menu-separator]
|
||||||
[:& menu-entry {:title (tr "workspace.shape.menu.add-flex")
|
[:& menu-entry {:title (tr "workspace.shape.menu.add-flex")
|
||||||
:shortcut (sc/get-tooltip :toggle-layout-flex)
|
:shortcut (sc/get-tooltip :toggle-layout-flex)
|
||||||
:on-click add-flex}]]
|
:on-click add-flex}]])
|
||||||
|
(when is-flex-container?
|
||||||
is-flex-container?
|
[:div
|
||||||
[:*
|
|
||||||
[:& menu-separator]
|
[:& menu-separator]
|
||||||
[:& menu-entry {:title (tr "workspace.shape.menu.remove-flex")
|
[:& menu-entry {:title (tr "workspace.shape.menu.remove-flex")
|
||||||
:shortcut (sc/get-tooltip :toggle-layout-flex)
|
:shortcut (sc/get-tooltip :toggle-layout-flex)
|
||||||
:on-click remove-flex}]])))
|
:on-click remove-flex}]])]))
|
||||||
|
|
||||||
(mf/defc context-menu-component
|
(mf/defc context-menu-component
|
||||||
[{:keys [shapes]}]
|
[{:keys [shapes]}]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue