From d30dc6b34be7f1e534d6e9869bae4b38bdfc8b97 Mon Sep 17 00:00:00 2001 From: Pablo Alba Date: Tue, 28 Nov 2023 14:10:55 +0100 Subject: [PATCH] :bug: Fix cut-paste main component outside another --- .../app/main/data/workspace/libraries_helpers.cljs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/main/data/workspace/libraries_helpers.cljs b/frontend/src/app/main/data/workspace/libraries_helpers.cljs index ecb34649e..6aa83d582 100644 --- a/frontend/src/app/main/data/workspace/libraries_helpers.cljs +++ b/frontend/src/app/main/data/workspace/libraries_helpers.cljs @@ -227,12 +227,23 @@ ([changes library-data component-id it page delta old-id parent-id] (let [component (ctkl/get-deleted-component library-data component-id) + parent (get-in page [:objects parent-id]) + inside-component? (some? (ctn/get-instance-root (:objects page) parent)) shapes (cfh/get-children-with-self (:objects component) (:main-instance-id component)) shapes (map #(gsh/move % delta) shapes) first-shape (cond-> (first shapes) (not (nil? parent-id)) - (assoc :parent-id parent-id)) + (assoc :parent-id parent-id) + (and parent (= :frame (:type parent))) + (assoc :frame-id parent-id) + (and parent (not= :frame (:type parent))) + (assoc :frame-id (:frame-id parent)) + inside-component? + (dissoc :component-root) + (not inside-component?) + (assoc :component-root true)) + changes (-> (or changes (pcb/empty-changes it)) (pcb/with-page page) (pcb/with-objects (:objects page))