From ace890c8097fed33fceffd35c35bc229c2a761d2 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Wed, 31 Jan 2024 16:42:56 +0100 Subject: [PATCH] :bug: Fix problem when changing main component with grid elements --- common/src/app/common/types/shape_tree.cljc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/common/src/app/common/types/shape_tree.cljc b/common/src/app/common/types/shape_tree.cljc index 064a3eae0..0b22b1a84 100644 --- a/common/src/app/common/types/shape_tree.cljc +++ b/common/src/app/common/types/shape_tree.cljc @@ -400,9 +400,21 @@ :parent-id parent-id :frame-id frame-id) + :always + ;; Store in the meta the old id so we can do a remap afterwards + ;; in the parent + (with-meta {::old-id (:id shape)}) + (some? (:shapes shape)) (assoc :shapes (mapv :id new-direct-children))) + ;; For a GRID layout remap the cells shapes' old-id to the new id given in the clone + new-shape + (if (ctl/grid-layout? new-shape) + (let [ids-map (into {} (map #(vector (-> % meta ::old-id) (:id %))) new-children)] + (ctl/remap-grid-cells new-shape ids-map)) + new-shape) + new-shape (update-new-shape new-shape shape) new-shapes (into [new-shape] new-children)