diff --git a/common/src/app/common/logic/libraries.cljc b/common/src/app/common/logic/libraries.cljc index 68537a7c58..0b654fbb42 100644 --- a/common/src/app/common/logic/libraries.cljc +++ b/common/src/app/common/logic/libraries.cljc @@ -694,7 +694,14 @@ (reorder-copy-children shape-inst children-main container)) (ctsl/grid-layout? shape-inst) - (update-grid-copy-attrs shape-before shape-main (not reset?)))))) + (update-grid-copy-attrs shape-before shape-main (not reset?)) + + ;; cells only carry between grids, so a copy that sync leaves + ;; without one drops its own + (and (not (ctsl/grid-layout? shape-inst)) (seq (:layout-grid-cells shape-inst))) + (pcb/update-shapes [(:id shape-inst)] + #(-> % (dissoc :layout-grid-cells) (update :touched disj :layout-grid-cells)) + {:ignore-touched true}))))) (defn generate-rename-component "Generate the changes for rename the component with the given id, in the current file library." diff --git a/common/test/common_tests/logic/composable_gen_test.cljc b/common/test/common_tests/logic/composable_gen_test.cljc index a079bdf4f5..8bda203af6 100644 --- a/common/test/common_tests/logic/composable_gen_test.cljc +++ b/common/test/common_tests/logic/composable_gen_test.cljc @@ -889,3 +889,15 @@ :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]]})))) + +(t/deftest generated-swap-to-a-board-without-grid-drops-a-copys-cell-override + ;; a copy authors the cells of a nested grid head; its main swaps the head + ;; for a component without grid, so the override has no grid to carry to + (let [result (cg/run {:world [2 0 {:variants true :text-styles true :layout :grid :grid-square true :library true + :rich-variants true :layout-copies true :text true}] + :ops [[:swap 5 0 0 0] [:grid-direction 1 0 0 1] [:grid-cell 1 0 0 1] [:swap 0 0 0 0]]}) + objects (into {} (mapcat cf/object-trees) (vals (cf/all-files (:situation result))))] + (doseq [shape (vals objects) + :when (not= :grid (:layout shape))] + (t/is (empty? (:layout-grid-cells shape)) (:name shape)) + (t/is (not (contains? (:touched shape) :layout-grid-cells)) (:name shape)))))