diff --git a/frontend/src/app/main/data/workspace/libraries.cljs b/frontend/src/app/main/data/workspace/libraries.cljs index 99a04096f..e6770c448 100644 --- a/frontend/src/app/main/data/workspace/libraries.cljs +++ b/frontend/src/app/main/data/workspace/libraries.cljs @@ -819,7 +819,9 @@ page libraries nil - (:parent-id shape)) + (:parent-id shape) + (:frame-id shape)) + ;; We need to set the same index as the original shape changes (pcb/change-parent changes (:parent-id shape) [new-shape] index {:component-swap true})] (rx/of (dch/commit-changes changes) diff --git a/frontend/src/app/main/data/workspace/libraries_helpers.cljs b/frontend/src/app/main/data/workspace/libraries_helpers.cljs index 98beec86f..b7aaa379e 100644 --- a/frontend/src/app/main/data/workspace/libraries_helpers.cljs +++ b/frontend/src/app/main/data/workspace/libraries_helpers.cljs @@ -144,9 +144,9 @@ (defn generate-instantiate-component "Generate changes to create a new instance from a component." ([changes objects file-id component-id position page libraries] - (generate-instantiate-component changes objects file-id component-id position page libraries nil nil)) + (generate-instantiate-component changes objects file-id component-id position page libraries nil nil nil)) - ([changes objects file-id component-id position page libraries old-id parent-id] + ([changes objects file-id component-id position page libraries old-id parent-id frame-id] (let [component (ctf/get-component libraries file-id component-id) parent (when parent-id (get objects parent-id)) library (get libraries file-id) @@ -168,7 +168,9 @@ (and (not (nil? parent)) (not= :frame (:type parent))) (assoc :frame-id (:frame-id parent)) (and (not (nil? parent)) (ctn/in-any-component? objects parent)) - (dissoc :component-root)) + (dissoc :component-root) + (and (nil? parent) (not (nil? frame-id))) + (assoc :frame-id frame-id)) ;; on copy/paste old id is used later to reorder the paster layers changes (cond-> (pcb/add-object changes first-shape {:ignore-touched true}) diff --git a/frontend/src/app/main/data/workspace/selection.cljs b/frontend/src/app/main/data/workspace/selection.cljs index 42ec617c2..105598503 100644 --- a/frontend/src/app/main/data/workspace/selection.cljs +++ b/frontend/src/app/main/data/workspace/selection.cljs @@ -380,7 +380,7 @@ (prepare-duplicate-guides shapes page ids-map delta))))) (defn- prepare-duplicate-component-change - [changes objects page component-root parent-id delta libraries library-data it] + [changes objects page component-root parent-id frame-id delta libraries library-data it] (let [component-id (:component-id component-root) file-id (:component-file component-root) main-component (ctf/get-component libraries file-id component-id) @@ -396,7 +396,8 @@ page libraries (:id component-root) - parent-id) + parent-id + frame-id) restore-component #(let [restore (dwlh/prepare-restore-component changes library-data (:component-id component-root) it page delta (:id component-root) parent-id)] @@ -419,7 +420,7 @@ changes (ctf/is-known-component? obj libraries) - (prepare-duplicate-component-change changes objects page obj parent-id delta libraries library-data it) + (prepare-duplicate-component-change changes objects page obj parent-id frame-id delta libraries library-data it) :else (let [frame? (cfh/frame-shape? obj)