diff --git a/common/src/app/common/logic/libraries.cljc b/common/src/app/common/logic/libraries.cljc index b5c0523876..a6ee7eaf99 100644 --- a/common/src/app/common/logic/libraries.cljc +++ b/common/src/app/common/logic/libraries.cljc @@ -1947,7 +1947,9 @@ order. In a copy without cell overrides, a reflow that moves items makes the cells an override, and one that moves none leaves the cells its main gives it, laid out as sync lays them out in the new direction, so a - copy that changes its direction back has its main's cells again." + copy that changes its direction back has its main's cells again. The main + of a swapped head is the root of its own component, which its content + follows." [file page libraries dir] (let [container (ctn/make-container page :page) objects (:objects page)] @@ -1958,7 +1960,7 @@ (let [reflowed (ctsl/reflow-grid-auto-items-for-direction shape from-dir dir) main (when (and (:shape-ref shape) (not (ctk/touched-group? shape :layout-grid-cells))) - (ctf/find-ref-shape file container libraries shape :include-deleted? true))] + (ctf/find-content-ref-shape file container libraries shape :include-deleted? true))] (cond (not= :grid (:layout main)) reflowed diff --git a/common/test/common_tests/logic/composable_gen_test.cljc b/common/test/common_tests/logic/composable_gen_test.cljc index aebf51e0c7..f882402f4f 100644 --- a/common/test/common_tests/logic/composable_gen_test.cljc +++ b/common/test/common_tests/logic/composable_gen_test.cljc @@ -1279,3 +1279,14 @@ [:nest 12 0 0 0] [:delete 6 0 0 0] [:detach 8 0 0 0] [:restore 0 0 0 0] [:duplicate 0 0 0 0] [:transform 3 3 0 8] [:delete 0] [:restore 0] [:edit 4 0 1 1] [:update-main 4] [:delete 0 0 0 0] [:transform 2 2 0 0]]})))) + +(t/deftest generated-direction-change-in-a-swapped-copy-overrides-its-moved-cells + ;; a copy that keeps another component than its main's slot takes its + ;; cells from its own component's main; a direction change that moves its + ;; items makes them an override, though the slot's board has no grid + (t/is (map? (cg/run {:world [2 2 {:variants true :text-styles true :library-variants true :stale-libraries true + :layout :grid :layout-item-margins false :grid-square true :library-depth 1 + :library true :rich-variants true :layout-children true :library-text true + :grid-empty false :layout-copies true :text true}] + :ops [[:delete 9 0 0 0] [:delete 0] [:restore 0] [:delete 17] [:restore 17] + [:swap 4 0 0 0] [:grid-direction 0 0 1 1] [:grid-cell 0 0 0 1]]}))))