diff --git a/common/src/app/common/logic/libraries.cljc b/common/src/app/common/logic/libraries.cljc index 6068ddb0db..6369264faf 100644 --- a/common/src/app/common/logic/libraries.cljc +++ b/common/src/app/common/logic/libraries.cljc @@ -660,11 +660,13 @@ (assoc shape :transform matrix :transform-inverse (gmt/inverse matrix)))) turn (orient-like (orientation before) (orientation after) (gsh/shape->center before)) delta (gpt/subtract (gsh/shape->center after) (gsh/shape->center before)) - ;; the subtree as the sync left it, under the parent placed as before the sync + ;; the subtree as the sync left it, under the parent placed as + ;; before the sync, its grid holding the children the sync left placed (when resized? - (placed-like (assoc (pcb/get-objects changes) (:id before) - (merge after (select-keys before placement-geometry-attrs))) - before after {}))] + (let [objects (pcb/get-objects changes) + parent (cond-> (merge after (select-keys before placement-geometry-attrs)) + (ctsl/grid-layout? after) (ctsl/assign-cells objects))] + (placed-like (assoc objects (:id before) parent) before after {})))] (pcb/update-shapes changes ids (if resized? #(get placed (:id %) %) diff --git a/common/test/common_tests/logic/composable_gen_test.cljc b/common/test/common_tests/logic/composable_gen_test.cljc index 74f7892634..1f9989c81b 100644 --- a/common/test/common_tests/logic/composable_gen_test.cljc +++ b/common/test/common_tests/logic/composable_gen_test.cljc @@ -2052,6 +2052,12 @@ [:make-variant 0] [:switch 0] [:make-variant 8 0 0 0] [:make-variant 0] [:switch 2] [:transform 10 4 0 0] [:make-variant 0] [:switch 17]]})))) +(t/deftest swapping-a-resized-board-for-a-grid-component-places-its-old-children-in-cells + (t/is (map? (cg/run {:world [1 0 {:variants true :text-styles false :layout :grid :variant-diff false + :layout-item-margins false :grid-square false :rich-variants true + :layout-children false :grid-empty false :layout-copies false :text false}] + :ops [[:combine 2] [:switch] [:swap 3]]})))) + (t/deftest turning-a-flipped-copy-turns-a-child-stored-as-the-other-mirror-turn (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