From 3f316ca9c908e947b9f09ae2676f3e36de3cd18b Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Tue, 12 Mar 2024 14:14:47 +0100 Subject: [PATCH] :bug: Fix swap on anidated frames --- frontend/src/app/main/data/workspace/libraries.cljs | 3 ++- .../src/app/main/data/workspace/libraries_helpers.cljs | 10 +++++++--- frontend/src/app/main/data/workspace/selection.cljs | 3 ++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/frontend/src/app/main/data/workspace/libraries.cljs b/frontend/src/app/main/data/workspace/libraries.cljs index 448997208..2d69cf7b6 100644 --- a/frontend/src/app/main/data/workspace/libraries.cljs +++ b/frontend/src/app/main/data/workspace/libraries.cljs @@ -901,7 +901,8 @@ libraries nil (:parent-id shape) - (:frame-id shape)) + (:frame-id shape) + {:force-frame? true}) new-shape (cond-> new-shape (nil? (ctk/get-swap-slot 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 b75f13e00..b3aa937db 100644 --- a/frontend/src/app/main/data/workspace/libraries_helpers.cljs +++ b/frontend/src/app/main/data/workspace/libraries_helpers.cljs @@ -152,9 +152,11 @@ (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 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 frame-id] + ([changes objects file-id component-id position page libraries old-id parent-id frame-id + {:keys [force-frame?] + :or {force-frame? false}}] (let [component (ctf/get-component libraries file-id component-id) parent (when parent-id (get objects parent-id)) library (get libraries file-id) @@ -166,7 +168,9 @@ component (:data library) position - components-v2) + components-v2 + (cond-> {} + force-frame? (assoc :force-frame-id frame-id))) first-shape (cond-> (first new-shapes) (not (nil? parent-id)) diff --git a/frontend/src/app/main/data/workspace/selection.cljs b/frontend/src/app/main/data/workspace/selection.cljs index ca4200c11..975e21704 100644 --- a/frontend/src/app/main/data/workspace/selection.cljs +++ b/frontend/src/app/main/data/workspace/selection.cljs @@ -443,7 +443,8 @@ libraries (:id component-root) parent-id - frame-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 frame-id)]