diff --git a/common/src/app/common/logic/variants.cljc b/common/src/app/common/logic/variants.cljc index 2c2c75fd1a..551f818694 100644 --- a/common/src/app/common/logic/variants.cljc +++ b/common/src/app/common/logic/variants.cljc @@ -391,14 +391,12 @@ main-parent (if position (get-in (meta position) [:container :objects (:parent-id position)]) main-parent) - parent-delta (if (and (:shape-ref parent) (nil? position)) 0 + rotation (mod (+ (or (:rotation baseline) 0) (- (or (:rotation parent) 0) (or (:rotation main-parent) 0))) - rotation (mod (+ (or (:rotation baseline) 0) parent-delta) 360) + 360) flip (fn [key] - (if (and (:shape-ref parent) (nil? position)) - (boolean (get baseline key)) - (odd? (count (filter identity [(get baseline key) (get parent key) - (get main-parent key)]))))) + (odd? (count (filter identity [(get baseline key) (get parent key) + (get main-parent key)])))) changed? (or (not (mth/close? (mod (or (:rotation shape) 0) 360) rotation 0.01)) (not= (boolean (:flip-x shape)) (flip :flip-x)) (not= (boolean (:flip-y shape)) (flip :flip-y)))] diff --git a/common/test/common_tests/logic/composable_gen_test.cljc b/common/test/common_tests/logic/composable_gen_test.cljc index dd058efafb..12dca7c569 100644 --- a/common/test/common_tests/logic/composable_gen_test.cljc +++ b/common/test/common_tests/logic/composable_gen_test.cljc @@ -1210,3 +1210,12 @@ :layout-item-margins false :grid-square false :rich-variants true :layout-children false :grid-empty false :layout-copies true :text true}] :ops [[:rotate 0 0 0 0] [:update-main 0 0 0 0] [:resize 0 0 0 0] [:switch 4 0 0 0]]})))) + +(t/deftest generated-switch-in-a-copy-keeps-a-turn-that-cancels-its-parents + ;; a copy child shows no turn: its near main's half turn cancels its turned + ;; copy parent's; a switch keeps that authored turn as an override + (t/is (map? (cg/run {:world [2 2 {:variants true :text-styles true :layout nil :variant-diff false + :layout-item-margins false :grid-square false :rich-variants true + :layout-children false :grid-empty false :layout-copies true :text true}] + :ops [[:duplicate 0 0 0 0] [:rotate 16 0 7 0] [:duplicate 0 0 0 0] [:rotate 16 0 7 0] + [:switch 12 0 0 0]]}))))