diff --git a/common/src/app/common/types/path.cljc b/common/src/app/common/types/path.cljc index 66996ddd3b..4581e481ef 100644 --- a/common/src/app/common/types/path.cljc +++ b/common/src/app/common/types/path.cljc @@ -178,9 +178,12 @@ base-content (segment/transform-content content (gmt/transform-in center transform-inverse)) - ;; Calculates the new selrect with points given the old center + ;; Calculates the new selrect with points given the old center; an + ;; empty content keeps the shape at that center points - (-> (segment/content->selrect base-content) + (-> (if (pos? (count base-content)) + (segment/content->selrect base-content) + (grc/center->rect center 0.01)) (grc/rect->points) (gco/transform-points center transform)) diff --git a/common/test/common_tests/logic/composable_gen_test.cljc b/common/test/common_tests/logic/composable_gen_test.cljc index 2ea6a87338..5f8f6b0f12 100644 --- a/common/test/common_tests/logic/composable_gen_test.cljc +++ b/common/test/common_tests/logic/composable_gen_test.cljc @@ -2430,6 +2430,12 @@ :grid-empty false :layout-copies false :text false}] :ops [[:transform 0 2 0 7] [:delete] [:switch] [:transform 1 1]]})))) +(t/deftest settling-a-bool-in-a-grid-copy-twice-keeps-its-shapes-in-place + (t/is (map? (cg/run {:world [3 0 {:variants true :rich-variants true :text true :layout :grid + :layout-copies true :layout-children true}] + :ops [[:rotate 16 0 7 0] [:grid-direction 0 0 0 1] [:grid-cell 0 10 0 1] [:add-child 0] + [:structure 3 6 15] [:grid-direction 0 0 0 1] [:grid-cell 0 4 2 1]]})))) + (t/deftest random-shape-structure-compositions (let [coverage (atom {}) failure (atom nil)] diff --git a/common/test/common_tests/types/path_data_test.cljc b/common/test/common_tests/types/path_data_test.cljc index 6c1b957691..42a40d3abc 100644 --- a/common/test/common_tests/types/path_data_test.cljc +++ b/common/test/common_tests/types/path_data_test.cljc @@ -2864,3 +2864,18 @@ result (path/splice-content content sub)] (t/is (path.impl/path-data? result)) (t/is (= (into (vec content) sub) (vec result))))) + +(t/deftest an-empty-turned-shape-keeps-its-place-when-its-geometry-updates + (let [center (gpt/point 135 197) + transform (gmt/rotate-matrix 180) + shape {:type :bool + :content [] + :selrect (grc/center->rect center 0.01) + :transform transform + :transform-inverse (gmt/inverse transform)} + updated (path/update-geometry shape) + twice (path/update-geometry updated)] + (t/is (mth/close? 135 (:x (grc/rect->center (:selrect updated))) 0.01)) + (t/is (mth/close? 197 (:y (grc/rect->center (:selrect updated))) 0.01)) + (t/is (mth/close? 135 (:x (grc/rect->center (:selrect twice))) 0.01)) + (t/is (mth/close? 197 (:y (grc/rect->center (:selrect twice))) 0.01))))