From 7e4e10ee08de8645ec680d3db9ae0fa8cc0e3d10 Mon Sep 17 00:00:00 2001 From: Pablo Alba Date: Wed, 22 Nov 2023 17:37:50 +0100 Subject: [PATCH] :bug: Fix validation error on moving a copy or main out of a main --- frontend/src/app/main/data/workspace/transforms.cljs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/frontend/src/app/main/data/workspace/transforms.cljs b/frontend/src/app/main/data/workspace/transforms.cljs index 57a971c4da..951962aa38 100644 --- a/frontend/src/app/main/data/workspace/transforms.cljs +++ b/frontend/src/app/main/data/workspace/transforms.cljs @@ -843,6 +843,12 @@ ;; Remove component-root property when moving a shape inside a component (cond-> (ctn/get-instance-root objects frame) (pcb/update-shapes moving-shapes-ids #(dissoc % :component-root))) + ;; Add component-root property when moving a component outside a component + (cond-> (not (ctn/get-instance-root objects frame)) + (pcb/update-shapes moving-shapes-ids (fn [shape] + (if (ctk/instance-head? shape) + (assoc shape :component-root true) + shape)))) (pcb/update-shapes moving-shapes-ids #(cond-> % (cfh/frame-shape? %) (assoc :hide-in-viewer true))) (pcb/update-shapes shape-ids-to-detach ctk/detach-shape) (pcb/change-parent frame-id moving-shapes drop-index)