diff --git a/common/src/app/common/logic/variants.cljc b/common/src/app/common/logic/variants.cljc index 0f28db4a9c..461ddec047 100644 --- a/common/src/app/common/logic/variants.cljc +++ b/common/src/app/common/logic/variants.cljc @@ -504,7 +504,8 @@ parent (get objects (:parent-id shape)) container (ctn/make-container (assoc page :objects objects) :page)] (if (and (:shape-ref parent) (not (ctk/swapped? shape))) - (let [component (ctf/find-ref-component nil container libraries shape) + (let [component (ctf/find-ref-component nil container libraries shape + :include-deleted? true) head (d/seek #(= (:id component) (:component-id %)) (ctn/get-parent-copy-heads objects parent))] (if head diff --git a/common/test/common_tests/logic/swap_group_test.cljc b/common/test/common_tests/logic/swap_group_test.cljc index 9820cd04a0..7dd6d90214 100644 --- a/common/test/common_tests/logic/swap_group_test.cljc +++ b/common/test/common_tests/logic/swap_group_test.cljc @@ -1079,3 +1079,14 @@ (t/is (= (:fills head) (:fills (ths/get-shape-by-id full (:id head))))) (t/is (= (thn/normalize-file (tm/file edited)) (thn/normalize-file (tm/file (r/step swapped (n/undo)))))))) + +(t/deftest swapping-back-in-a-copy-of-a-deleted-component-inherits-its-position + (let [edited (-> (tm/make-situation (setup)) + (r/step (n/change-property :card-star :fills "#333333")) r/settle) + deleted (-> edited (r/step (n/delete-component :card-main)) r/settle) + swapped (-> deleted (r/step (n/swap-shape :copy-star :star)) r/settle) + head (tm/resolve-shape swapped :copy-star)] + (t/is (= "#333333" (get-in head [:fills 0 :fill-color]))) + (t/is (empty? (:touched head))) + (t/is (= (thn/normalize-file (tm/file deleted)) + (thn/normalize-file (tm/file (r/step swapped (n/undo))))))))