diff --git a/common/src/app/common/logic/libraries.cljc b/common/src/app/common/logic/libraries.cljc index d6cc6c57e1..ecf0533919 100644 --- a/common/src/app/common/logic/libraries.cljc +++ b/common/src/app/common/logic/libraries.cljc @@ -727,7 +727,11 @@ ;; how close the axes of `m` are to those of the shape closeness (fn [m] (+ (* (:a m) (:a axes)) (* (:b m) (:b axes)) (* (:c m) (:c axes)) (* (:d m) (:d axes)))) - transform (max-key closeness (gmt/multiply turn flips) (gmt/multiply flips turn))] + turned (gmt/multiply turn flips) + flipped (gmt/multiply flips turn) + ;; axes that tell neither apart, as those of a bool fitting resets, + ;; take the turn before the flips, as a flip of a turned shape stores + transform (if (>= (closeness turned) (closeness flipped)) turned flipped)] (assoc shape :transform transform :transform-inverse (gmt/inverse transform)))) (defn- layout-skewed? diff --git a/common/test/common_tests/logic/composable_gen_test.cljc b/common/test/common_tests/logic/composable_gen_test.cljc index 1ab6b782c8..27995cf474 100644 --- a/common/test/common_tests/logic/composable_gen_test.cljc +++ b/common/test/common_tests/logic/composable_gen_test.cljc @@ -4328,3 +4328,13 @@ :layout-children false :grid-empty false :layout-copies false :text false}] :ops [[:delete 5] [:restore] [:add-variant] [:switch] [:add-variant] [:variant-property 0 1] [:switch 13] [:style 5 8 7] [:add-variant]]})))) + +(t/deftest generated-a-flipped-turned-bool-gives-its-children-its-orientation + ;; a bool that a sync fits keeps its turn and flips; its children take + ;; the turn before the flips, as the flip of a turned shape stores them + (t/is (map? (cg/run {:world [2 0 {:variants true :rich-variants true :text true :layout :grid + :layout-copies false :layout-children true}] + :ops [[:add-child 12] [:structure 23 5 7] [:rotate] [:switch] [:transform 2 22 0 27]]}))) + (t/is (map? (cg/run {:world [2 0 {:variants true :rich-variants true :text true :layout :grid + :layout-copies false :layout-children false}] + :ops [[:duplicate] [:structure 0 4] [:swap 7] [:rotate 11] [:transform 1 11 0 12]]}))))