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 e654a9d6e1..69772f8c01 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])) @@ -617,3 +618,11 @@ (catch #?(:clj Exception :cljs js/Error) error error))] (t/is (= ::tm/unbound-shape-name (:type (ex-data error)))) (t/is (some #{:copy-child} (:present (ex-data error)))))) + +(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))))))))