mirror of
https://github.com/penpot/penpot.git
synced 2025-08-06 15:08:27 +02:00
🐛 Fix 'Create component' option is absent in context menu when user has selected multiple layers
This commit is contained in:
parent
9ff3095568
commit
2e27a5b4b6
1 changed files with 14 additions and 11 deletions
|
@ -12,6 +12,7 @@
|
||||||
[app.common.data.macros :as dm]
|
[app.common.data.macros :as dm]
|
||||||
[app.common.pages.helpers :as cph]
|
[app.common.pages.helpers :as cph]
|
||||||
[app.common.types.component :as ctk]
|
[app.common.types.component :as ctk]
|
||||||
|
[app.common.types.container :as ctn]
|
||||||
[app.common.types.page :as ctp]
|
[app.common.types.page :as ctp]
|
||||||
[app.common.uuid :as uuid]
|
[app.common.uuid :as uuid]
|
||||||
[app.main.data.events :as ev]
|
[app.main.data.events :as ev]
|
||||||
|
@ -442,21 +443,23 @@
|
||||||
|
|
||||||
(mf/defc context-menu-component
|
(mf/defc context-menu-component
|
||||||
[{:keys [shapes]}]
|
[{:keys [shapes]}]
|
||||||
(let [single? (= (count shapes) 1)
|
(let [components-v2 (features/use-feature :components-v2)
|
||||||
shapes (filter ctk/instance-head? shapes)
|
single? (= (count shapes) 1)
|
||||||
components-v2 (features/use-feature :components-v2)
|
objects (deref refs/workspace-page-objects)
|
||||||
in-main? (some true? (map #(ctk/main-instance? %) shapes))
|
any-in-copy? (some true? (map #(ctn/has-any-copy-parent? objects %) shapes))
|
||||||
components-menu-entries (cmm/generate-components-menu-entries shapes components-v2)
|
heads (filter ctk/instance-head? shapes)
|
||||||
do-add-component #(st/emit! (dwl/add-component))
|
components-menu-entries (cmm/generate-components-menu-entries heads components-v2)
|
||||||
|
do-add-component #(st/emit! (dwl/add-component))
|
||||||
do-add-multiple-components #(st/emit! (dwl/add-multiple-components))]
|
do-add-multiple-components #(st/emit! (dwl/add-multiple-components))]
|
||||||
[:*
|
[:*
|
||||||
(when-not in-main?
|
(when-not any-in-copy? ;; We don't want to change the structure of component copies
|
||||||
[:*
|
[:*
|
||||||
[:& menu-separator]
|
[:& menu-separator]
|
||||||
(if single?
|
|
||||||
[:& menu-entry {:title (tr "workspace.shape.menu.create-component")
|
[:& menu-entry {:title (tr "workspace.shape.menu.create-component")
|
||||||
:shortcut (sc/get-tooltip :create-component)
|
:shortcut (sc/get-tooltip :create-component)
|
||||||
:on-click do-add-component}]
|
:on-click do-add-component}]
|
||||||
|
(when (not single?)
|
||||||
[:& menu-entry {:title (tr "workspace.shape.menu.create-multiple-components")
|
[:& menu-entry {:title (tr "workspace.shape.menu.create-multiple-components")
|
||||||
:on-click do-add-multiple-components}])])
|
:on-click do-add-multiple-components}])])
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue