diff --git a/frontend/src/app/main/data/workspace/libraries_helpers.cljs b/frontend/src/app/main/data/workspace/libraries_helpers.cljs index b35e303587..67ff5c991c 100644 --- a/frontend/src/app/main/data/workspace/libraries_helpers.cljs +++ b/frontend/src/app/main/data/workspace/libraries_helpers.cljs @@ -134,8 +134,7 @@ (let [main-instance-page (ctf/get-component-page library-data component) main-instance-shape (ctf/get-component-root library-data component) - position (gpt/add (gpt/point (:x main-instance-shape) (:y main-instance-shape)) - (gpt/point (+ (:width main-instance-shape) 50) 0)) + position (gpt/point (:x main-instance-shape) (:y main-instance-shape)) component-instance-extra-data (if components-v2 {:main-instance? true} {}) diff --git a/frontend/src/app/main/data/workspace/selection.cljs b/frontend/src/app/main/data/workspace/selection.cljs index c4a97ec2cf..64a5673458 100644 --- a/frontend/src/app/main/data/workspace/selection.cljs +++ b/frontend/src/app/main/data/workspace/selection.cljs @@ -14,6 +14,7 @@ [app.common.pages :as cp] [app.common.pages.changes-builder :as pcb] [app.common.pages.helpers :as cph] + [app.common.types.component :as ctk] [app.common.types.file :as ctf] [app.common.types.page :as ctp] [app.common.types.shape.interactions :as ctsi] @@ -565,7 +566,9 @@ (defn calc-duplicate-delta [obj state objects] (let [{:keys [id-original id-duplicated]} - (get-in state [:workspace-local :duplicated])] + (get-in state [:workspace-local :duplicated]) + move? (and (cph/frame-shape? obj) + (not (ctk/instance-head? obj)))] (if (or (and (not= id-original (:id obj)) (not= id-duplicated (:id obj))) ;; As we can remove duplicated elements may be we can still caching a deleted id @@ -574,7 +577,7 @@ ;; The default is leave normal shapes in place, but put ;; new frames to the right of the original. - (if (cph/frame-shape? obj) + (if move? (gpt/point (+ (:width obj) 50) 0) (gpt/point 0 0)) diff --git a/frontend/src/app/main/ui/workspace/context_menu.cljs b/frontend/src/app/main/ui/workspace/context_menu.cljs index 5fe7136e89..39519e4646 100644 --- a/frontend/src/app/main/ui/workspace/context_menu.cljs +++ b/frontend/src/app/main/ui/workspace/context_menu.cljs @@ -149,23 +149,12 @@ (dom/classnames :separator true))}])) (mf/defc context-menu-edit - [props] - (let [shapes (:shapes props) - main-component-id (when (and (= 1 (count shapes)) - (:main-instance? (first shapes))) - (:component-id (first shapes))) - do-copy #(st/emit! (dw/copy-selected)) + [_] + (let [do-copy #(st/emit! (dw/copy-selected)) do-cut #(st/emit! (dw/copy-selected) (dw/delete-selected)) do-paste #(st/emit! dw/paste) - do-duplicate #(if main-component-id - (st/emit! (dwl/duplicate-component (:component-file (first shapes)) main-component-id)) - (st/emit! (dw/duplicate-selected false))) - - - duplicate-title (if main-component-id - (tr "workspace.assets.duplicate-main") - (tr "workspace.shape.menu.duplicate"))] + do-duplicate #(st/emit! (dw/duplicate-selected true))] [:* [:& menu-entry {:title (tr "workspace.shape.menu.copy") :shortcut (sc/get-tooltip :copy) @@ -176,7 +165,7 @@ [:& menu-entry {:title (tr "workspace.shape.menu.paste") :shortcut (sc/get-tooltip :paste) :on-click do-paste}] - [:& menu-entry {:title duplicate-title + [:& menu-entry {:title (tr "workspace.shape.menu.duplicate") :shortcut (sc/get-tooltip :duplicate) :on-click do-duplicate}]