From 45072c19a2732bdb53c34beecef4dcbe0ab12868 Mon Sep 17 00:00:00 2001 From: Pablo Alba Date: Tue, 16 Jan 2024 19:07:08 +0100 Subject: [PATCH] :bug: Fix on cut and paste a component, a bad frame-id is set --- .../src/app/main/data/workspace/libraries_helpers.cljs | 10 ++++++---- frontend/src/app/main/data/workspace/selection.cljs | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/frontend/src/app/main/data/workspace/libraries_helpers.cljs b/frontend/src/app/main/data/workspace/libraries_helpers.cljs index b81f78e71f..c9057dc1ad 100644 --- a/frontend/src/app/main/data/workspace/libraries_helpers.cljs +++ b/frontend/src/app/main/data/workspace/libraries_helpers.cljs @@ -247,9 +247,9 @@ (when (some #(= (:id current-page) %) (:pages library-data)) ;; If the page doesn't belong to the library, it's not valid current-page) (ctpl/get-last-page library-data))] - (prepare-restore-component nil library-data component-id it page (gpt/point 0 0) nil nil))) + (prepare-restore-component nil library-data component-id it page (gpt/point 0 0) nil nil nil))) - ([changes library-data component-id it page delta old-id parent-id] + ([changes library-data component-id it page delta old-id parent-id frame-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)) @@ -259,9 +259,11 @@ first-shape (cond-> (first shapes) (not (nil? parent-id)) (assoc :parent-id parent-id) - (and parent (= :frame (:type parent))) + (not (nil? frame-id)) + (assoc :frame-id frame-id) + (and (nil? frame-id) parent (= :frame (:type parent))) (assoc :frame-id parent-id) - (and parent (not= :frame (:type parent))) + (and (nil? frame-id) parent (not= :frame (:type parent))) (assoc :frame-id (:frame-id parent)) inside-component? (dissoc :component-root) diff --git a/frontend/src/app/main/data/workspace/selection.cljs b/frontend/src/app/main/data/workspace/selection.cljs index 5ee865400f..05742a14bd 100644 --- a/frontend/src/app/main/data/workspace/selection.cljs +++ b/frontend/src/app/main/data/workspace/selection.cljs @@ -418,7 +418,7 @@ 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)] + #(let [restore (dwlh/prepare-restore-component changes library-data (:component-id component-root) it page delta (:id component-root) parent-id frame-id)] [(:shape restore) (:changes restore)]) [_shape changes]