diff --git a/common/src/app/common/logic/libraries.cljc b/common/src/app/common/logic/libraries.cljc index 35dc408308..68537a7c58 100644 --- a/common/src/app/common/logic/libraries.cljc +++ b/common/src/app/common/logic/libraries.cljc @@ -2068,11 +2068,14 @@ (defn generate-reset-component "Reset the copy head to its near main. A swapped head turns back into the component of the main shape it refers to, keeping its id. A nested head - also takes its position's placement and inherited layout item values." + also takes its position's placement and inherited layout item values, + and its grid parent's cells follow when that takes it in or out of the + flow." [changes file-full libraries container id] (-> changes (pcb/with-container container) (pcb/with-objects (:objects container)) (generate-sync-shape-direct file-full libraries container id true) (settle-reset-placement file-full libraries container id) - (reset-layout-item file-full libraries container id))) + (reset-layout-item file-full libraries container id) + (reassign-parent-grid-cells container id))) diff --git a/common/test/common_tests/logic/composable_gen_test.cljc b/common/test/common_tests/logic/composable_gen_test.cljc index 086b3e8852..a079bdf4f5 100644 --- a/common/test/common_tests/logic/composable_gen_test.cljc +++ b/common/test/common_tests/logic/composable_gen_test.cljc @@ -881,3 +881,11 @@ (t/is (map? (cg/run {:world [2 2 {:variants true :text-styles true :layout :flex :library true :rich-variants true :layout-copies true :text true}] :ops [[:transform 7 0 0 8] [:delete 0] [:restore 0] [:add-child 9 0 0 0]]})))) + +(t/deftest generated-reset-of-an-absolute-grid-head-gives-it-back-its-cell + ;; a copy makes a nested head absolute and authors its grid's cells; the + ;; reset takes the head back into the flow and into a cell + (t/is (map? (cg/run {:world [2 1 {:variants true :text-styles true :library-variants true :stale-libraries true + :layout :grid :library-depth 1 :library true :rich-variants true + :layout-children true :library-text true :layout-copies true :text true}] + :ops [[:style 11 35 1] [:grid-direction 13 0 0 1] [:grid-cell 13 0 0 1] [:reset 14 0 0 0]]}))))