diff --git a/common/src/app/common/logic/swap.cljc b/common/src/app/common/logic/swap.cljc index 7b5d79b2d9..8b228be4ca 100644 --- a/common/src/app/common/logic/swap.cljc +++ b/common/src/app/common/logic/swap.cljc @@ -261,8 +261,12 @@ :else (get previous-shape attr)))] - ;; If the final attr-value is the actual value, skip - (if (or skip? (= attr-val (get current-shape attr))) + ;; If the final attr-value is the actual value, skip. Geometry values + ;; equal up to float noise are not an override. + (if (or skip? + (if (contains? #{:points :selrect :width :height :rotation} attr) + (gsh/close-attrs? attr attr-val (get current-shape attr)) + (= attr-val (get current-shape attr)))) [] (cond-> [] ;; On a text-change, we want to force a position-data reset diff --git a/common/test/common_tests/logic/composable_gen_test.cljc b/common/test/common_tests/logic/composable_gen_test.cljc index 227e4e33ef..24280ef9c6 100644 --- a/common/test/common_tests/logic/composable_gen_test.cljc +++ b/common/test/common_tests/logic/composable_gen_test.cljc @@ -662,6 +662,15 @@ (t/is (gsh/close-attrs? :height 40 (:height expected) 0.01)) (t/is (gsh/close-attrs? :height 40 (:height child) 0.01)))) +(t/deftest switching-to-an-equally-rotated-variant-adds-no-geometry-override + ;; The swapped copy keeps a 45 degree turn, which the new variant main + ;; already has after update-main; the switch result differs only by noise. + (t/is (map? (cg/run {:world [2 0 {:variants true :text-styles true :layout nil :layout-item-margins false + :library true :rich-variants true :layout-children false + :layout-copies true :text true}] + :ops [[:rotate 0 0 0 0] [:edit 0 0 1 1] [:update-main 0] [:delete 0] + [:restore 0] [:nest 0 0 0 0] [:swap 0 0 0 0] [:switch 0 0 0 0]]})))) + (t/deftest detached-swapped-head-follows-its-own-component-without-position-overrides (t/is (map? (cg/run {:world [2 1 {:library true :variants true}] :ops [[:edit 0 0 1 2] [:update-main 0] [:library-sync]