diff --git a/CHANGES.md b/CHANGES.md index e7d05cb56..5a2145b54 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -45,6 +45,7 @@ - Fix open overlay relative to a frame [Taiga #7563](https://tree.taiga.io/project/penpot/issue/7563) - Workspace-palette items stay hidden when opening with keyboard-shortcut [Taiga #7489](https://tree.taiga.io/project/penpot/issue/7489) - Fix SVG attrs are not handled correctly when exporting/importing in .zip [Taiga #7920](https://tree.taiga.io/project/penpot/issue/7920) +- Fix validation error when detaching with two nested copies and a swap [Taiga #8095](https://tree.taiga.io/project/penpot/issue/8095) ## 2.0.3 diff --git a/common/src/app/common/logic/libraries.cljc b/common/src/app/common/logic/libraries.cljc index ec40277e0..314970805 100644 --- a/common/src/app/common/logic/libraries.cljc +++ b/common/src/app/common/logic/libraries.cljc @@ -269,8 +269,8 @@ ; First level subinstances of a detached component can't have swap-slot (pcb/update-shapes [shape-id] ctk/remove-swap-slot) - :always - ; Near shape-refs need to be advanced one level + (nil? (ctk/get-swap-slot shape)) + ; Near shape-refs need to be advanced one level (except if the head is already swapped) (generate-advance-nesting-level nil container libraries (:id shape))) ;; Otherwise, detach the shape and all children diff --git a/frontend/src/debug.cljs b/frontend/src/debug.cljs index 5ff02f75f..9d79a2c24 100644 --- a/frontend/src/debug.cljs +++ b/frontend/src/debug.cljs @@ -277,15 +277,23 @@ (let [page-id (get state :current-page-id) file (assoc (get state :workspace-file) :data (get state :workspace-data)) - libraries (get state :workspace-libraries)] - (ctf/dump-subtree file page-id shape-id libraries {:show-ids show-ids - :show-touched show-touched - :show-modified show-modified})))) + libraries (get state :workspace-libraries) + shape-id (if (some? shape-id) + (uuid/uuid shape-id) + (let [objects (get-in state [:workspace-data :pages-index page-id :objects]) + selected (get-in state [:workspace-local :selected])] + (->> selected (map (d/getf objects)) first :id)))] + (if (some? shape-id) + (ctf/dump-subtree file page-id shape-id libraries {:show-ids show-ids + :show-touched show-touched + :show-modified show-modified}) + (println "no selected shape"))))) + (defn ^:export dump-subtree - ([shape-id] (dump-subtree' @st/state (uuid/uuid shape-id))) - ([shape-id show-ids] (dump-subtree' @st/state (uuid/uuid shape-id) show-ids false false)) - ([shape-id show-ids show-touched] (dump-subtree' @st/state (uuid/uuid shape-id) show-ids show-touched false)) - ([shape-id show-ids show-touched show-modified] (dump-subtree' @st/state (uuid/uuid shape-id) show-ids show-touched show-modified))) + ([shape-id] (dump-subtree' @st/state shape-id)) + ([shape-id show-ids] (dump-subtree' @st/state shape-id show-ids false false)) + ([shape-id show-ids show-touched] (dump-subtree' @st/state shape-id show-ids show-touched false)) + ([shape-id show-ids show-touched show-modified] (dump-subtree' @st/state shape-id show-ids show-touched show-modified))) (when *assert* (defonce debug-subscription