diff --git a/common/src/app/common/logic/libraries.cljc b/common/src/app/common/logic/libraries.cljc index 3c04750eca..293b6099e9 100644 --- a/common/src/app/common/logic/libraries.cljc +++ b/common/src/app/common/logic/libraries.cljc @@ -463,19 +463,21 @@ (d/ordered-map) (keep (fn [id] (let [shape (get objects id) - root (when (:component-id shape) (ctn/get-component-shape objects shape)) + root (when (:shape-ref shape) (ctn/get-component-shape objects shape)) old (get before id) - reflected-head? (and (:component-id shape) - (:shape-ref shape) - (or (not= (boolean (:flip-x old)) (boolean (:flip-x shape))) - (not= (boolean (:flip-y old)) (boolean (:flip-y shape)))))] + ;; a copy head, or a plain copy shape with children + reflected? (and (some? root) + (or (:component-id shape) (seq (:shapes shape))) + (or (not= (boolean (:flip-x old)) (boolean (:flip-x shape))) + (not= (boolean (:flip-y old)) (boolean (:flip-y shape)))))] (cond - (and (ctk/swapped? shape) + (and (some? root) + (ctk/swapped? shape) (not (ctk/touched-group? shape :geometry-group)) (not= (orientation old) (orientation shape))) [(:id root) true] - reflected-head? + reflected? [(:id root) false]))) ids))] (reduce (fn [changes [id resize?]] diff --git a/common/test/common_tests/logic/composable_gen_test.cljc b/common/test/common_tests/logic/composable_gen_test.cljc index a365befb25..b25da85c9a 100644 --- a/common/test/common_tests/logic/composable_gen_test.cljc +++ b/common/test/common_tests/logic/composable_gen_test.cljc @@ -312,6 +312,14 @@ (t/is (map? (cg/run {:world [2 1 {:text true :layout :grid}] :ops [[:rotate 1] [:transform 2 16 0 9]]})))) +(t/deftest reflecting-a-plain-copy-child-settles-descendant-flips + ;; the main detaches its nested copy, so the copy's nested head is a plain + ;; copy child; reflecting it leaves its turned child as a full sync does + (t/is (map? (cg/run {:world [3 1 {:text true :text-styles true :layout nil :layout-children false + :layout-item-margins false :grid-square false :grid-empty false}] + :ops [[:transform 3 9 1 7] [:remove-child 0 0 0 0] [:detach 4 0 0 0] + [:transform 0 4 0 7]]})))) + (t/deftest swapping-after-a-resized-variant-keeps-child-placement (t/is (map? (cg/run {:world [2 2 {:variants true :variant-diff false :rich-variants true :text true :layout nil :layout-copies true}]