diff --git a/common/src/app/common/logic/shapes.cljc b/common/src/app/common/logic/shapes.cljc index 4e6e78b50e..413eb9964c 100644 --- a/common/src/app/common/logic/shapes.cljc +++ b/common/src/app/common/logic/shapes.cljc @@ -132,8 +132,14 @@ ids))) changes (cond-> changes (seq grid-ids) - (-> (pcb/update-shapes grid-ids ctl/assign-cell-positions {:with-objects? true}) - (pcb/reorder-grid-children ids)) + (as-> changes + ;; a grid the update does not touch reassigns its cells as a consequence + (reduce (fn [changes id] + (pcb/update-shapes changes [id] ctl/assign-cell-positions + {:with-objects? true + :ignore-touched (boolean (or (true? (get ignore-tree id)) ignore-touched))})) + changes grid-ids) + (pcb/reorder-grid-children changes ids)) (seq hidden-grid-ids) (-> (pcb/update-shapes hidden-grid-ids ctl/assign-cells diff --git a/common/test/common_tests/logic/composable_gen_test.cljc b/common/test/common_tests/logic/composable_gen_test.cljc index 92a277349e..83677c227f 100644 --- a/common/test/common_tests/logic/composable_gen_test.cljc +++ b/common/test/common_tests/logic/composable_gen_test.cljc @@ -1077,3 +1077,10 @@ (t/is (map? (cg/run {:world [2 2 {:variants true :text-styles true :variant-diff false :rich-variants true :layout-copies true :text true}] :ops [[:resize 0 0 0 0] [:rotate 1 0 0 0] [:switch 4 0 0 0]]})))) + +(t/deftest generated-reflow-of-a-copy-grid-keeps-its-cells-inherited + ;; a copy child switched to a hidden variant leaves its grid cell; the + ;; layout reflow reassigns the copy grid's cells without authoring them + (t/is (map? (cg/run {:world [2 2 {:variants true :text-styles true :layout :grid :variant-diff false + :rich-variants true :layout-copies true :text true}] + :ops [[:nest 6 0 0 0] [:style 8 1 1] [:switch 4 0 0 0]]}))))