diff --git a/common/src/app/common/logic/variants.cljc b/common/src/app/common/logic/variants.cljc index 3a17c941e4..2c2c75fd1a 100644 --- a/common/src/app/common/logic/variants.cljc +++ b/common/src/app/common/logic/variants.cljc @@ -606,7 +606,7 @@ changes))) (defn- keep-moved-placement - "A switch keeps the place of the copy shape `original-shape` it replaces. + "A swap keeps the place of the copy shape `original-shape` it replaces. Inside a copy, a first corner that the position of `new-shape` would not give it needs a geometry override to survive later sync." [changes original-shape new-shape page libraries] @@ -672,10 +672,9 @@ changes (sync-restored-position changes page libraries (:id new-shape)) - changes (cond-> changes + changes (cond-> (keep-moved-placement changes shape new-shape page libraries) keep-touched? - (-> (keep-moved-placement shape new-shape page libraries) - (keep-placement-overrides shape new-shape))) + (keep-placement-overrides shape new-shape)) ;; Replacement keeps the head id and its cell. Cleanup during the ;; temporary deletion must not change the parent's placement data. diff --git a/common/test/common_tests/logic/composable_gen_test.cljc b/common/test/common_tests/logic/composable_gen_test.cljc index 87feb781f1..a365befb25 100644 --- a/common/test/common_tests/logic/composable_gen_test.cljc +++ b/common/test/common_tests/logic/composable_gen_test.cljc @@ -1100,3 +1100,11 @@ (t/is (map? (cg/run {:world [3 2 {:variants true :text-styles true :layout :flex :variant-diff false :rich-variants true :layout-children true :layout-copies true :text true}] :ops [[:delete 6 0 0 0] [:swap 20 0 0 0] [:nest 7 0 0 0] [:style 13 27 1] [:switch 0 0 0 0]]})))) + +(t/deftest generated-swap-keeps-a-moved-copy-child-in-place-as-its-own + ;; a copy child of a copy moved and swapped for another component keeps + ;; the moved place as its own geometry + (t/is (map? (cg/run {:world [2 2 {:variants true :text-styles true :layout nil :variant-diff false + :layout-item-margins false :grid-square false :rich-variants true + :layout-children false :grid-empty false :layout-copies true :text true}] + :ops [[:text 14 0 0 0] [:nest 0 0 0 0] [:transform 0 0 0 18] [:swap 12 0 0 0]]}))))