From bedaef961b271bb68170592c77c35b6e0475614e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Moya?= Date: Mon, 9 Jan 2023 14:21:29 +0100 Subject: [PATCH] :bug: Fix ghost shapes after sync groups in components --- CHANGES.md | 1 + .../data/workspace/libraries_helpers.cljs | 42 ++++++++++--------- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index b05b7c1a6..003089362 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -39,6 +39,7 @@ - Fix group/ungroup shapes inside a component [Taiga #4052](https://tree.taiga.io/project/penpot/issue/4052) - Fix wrong update of text in components [Taiga #4646](https://tree.taiga.io/project/penpot/issue/4646) - Fix problem with SVG imports with style [#2605](https://github.com/penpot/penpot/issues/2605) +- Fix ghost shapes after sync groups in components [Taiga #4649](https://tree.taiga.io/project/penpot/issue/4649) ## 1.16.2-beta diff --git a/frontend/src/app/main/data/workspace/libraries_helpers.cljs b/frontend/src/app/main/data/workspace/libraries_helpers.cljs index be91726d2..78c80455a 100644 --- a/frontend/src/app/main/data/workspace/libraries_helpers.cljs +++ b/frontend/src/app/main/data/workspace/libraries_helpers.cljs @@ -915,32 +915,36 @@ parents (cph/get-parent-ids objects (:id shape)) parent (first parents) children (cph/get-children-ids objects (:id shape)) + ids (into [(:id shape)] children) + + add-redo-change (fn [changes id] + (update changes :redo-changes conj + (make-change + container + {:type :del-obj + :id id + :ignore-touched true}))) add-undo-change (fn [changes id] (let [shape' (get objects id)] (update changes :undo-changes d/preconj (make-change - container - (as-> {:type :add-obj - :id id - :index (cph/get-position-on-parent objects id) - :parent-id (:parent-id shape') - :ignore-touched true - :obj shape'} $ - (cond-> $ - (:frame-id shape') - (assoc :frame-id (:frame-id shape')))))))) + container + (as-> {:type :add-obj + :id id + :index (cph/get-position-on-parent objects id) + :parent-id (:parent-id shape') + :ignore-touched true + :obj shape'} $ + (cond-> $ + (:frame-id shape') + (assoc :frame-id (:frame-id shape')))))))) - changes' (-> changes + changes' (-> (reduce add-redo-change changes ids) (update :redo-changes conj (make-change - container - {:type :del-obj - :id (:id shape) - :ignore-touched true})) - (update :redo-changes conj (make-change - container - {:type :reg-objects - :shapes (vec parents)})) + container + {:type :reg-objects + :shapes (vec parents)})) (add-undo-change (:id shape))) changes' (reduce add-undo-change