diff --git a/common/src/app/common/files/shapes_helpers.cljc b/common/src/app/common/files/shapes_helpers.cljc index 4540501938..fa80bb84e4 100644 --- a/common/src/app/common/files/shapes_helpers.cljc +++ b/common/src/app/common/files/shapes_helpers.cljc @@ -36,7 +36,8 @@ (cond-> (some? cell) (pcb/update-shapes [(:parent-id shape)] #(ctl/push-into-cell % [id] row column))) (cond-> (ctl/grid-layout? objects (:parent-id shape)) - (pcb/update-shapes [(:parent-id shape)] ctl/assign-cells {:with-objects? true})))] + (-> (pcb/update-shapes [(:parent-id shape)] ctl/assign-cells {:with-objects? true}) + (pcb/reorder-grid-children [(:parent-id shape)]))))] [shape changes])) diff --git a/common/test/common_tests/logic/composable_runner_test.cljc b/common/test/common_tests/logic/composable_runner_test.cljc index ca25ec8285..ae60b01f81 100644 --- a/common/test/common_tests/logic/composable_runner_test.cljc +++ b/common/test/common_tests/logic/composable_runner_test.cljc @@ -16,6 +16,7 @@ [app.common.test-helpers.files :as thf] [app.common.test-helpers.ids-map :as thi] [app.common.test-helpers.normalize :as thn] + [app.common.types.shape.layout :as ctl] [app.common.uuid :as uuid] [clojure.test :as t])) @@ -583,3 +584,11 @@ (t/is false) (reset! counted @made)))) (t/is (= 2 @counted)))) + +(t/deftest adding-a-grid-child-records-cell-order-before-reflow + (let [initial (setup/grid-component-with-copy) + changed (-> initial (r/step (n/add-child :grid-root :new-grid-child)) r/settle) + grid (tm/resolve-shape changed :grid-root)] + (t/is (= (:shapes (ctl/reorder-grid-children grid)) (:shapes grid))) + (t/is (= (thn/normalize-file (tm/file initial)) + (thn/normalize-file (tm/file (r/step changed (n/undo))))))))