diff --git a/frontend/src/app/main/data/workspace/libraries.cljs b/frontend/src/app/main/data/workspace/libraries.cljs index 046bc6dfd..99a04096f 100644 --- a/frontend/src/app/main/data/workspace/libraries.cljs +++ b/frontend/src/app/main/data/workspace/libraries.cljs @@ -817,7 +817,10 @@ id-new-component position page - libraries) + libraries + nil + (:parent-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) (ptk/data-event :layout/update [(:id new-shape)]) diff --git a/frontend/src/app/main/data/workspace/libraries_helpers.cljs b/frontend/src/app/main/data/workspace/libraries_helpers.cljs index 7e78d314b..98beec86f 100644 --- a/frontend/src/app/main/data/workspace/libraries_helpers.cljs +++ b/frontend/src/app/main/data/workspace/libraries_helpers.cljs @@ -148,6 +148,7 @@ ([changes objects file-id component-id position page libraries old-id parent-id] (let [component (ctf/get-component libraries file-id component-id) + parent (when parent-id (get objects parent-id)) library (get libraries file-id) components-v2 (dm/get-in library [:data :options :components-v2]) @@ -161,7 +162,13 @@ first-shape (cond-> (first new-shapes) (not (nil? parent-id)) - (assoc :parent-id parent-id)) + (assoc :parent-id parent-id) + (and (not (nil? parent)) (= :frame (:type parent))) + (assoc :frame-id (:id parent)) + (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)) ;; on copy/paste old id is used later to reorder the paster layers changes (cond-> (pcb/add-object changes first-shape {:ignore-touched true})