From 8c2ef98bb275873a2b2b797228bef5f9176582ae Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Fri, 13 Nov 2026 02:05:30 +0100 Subject: [PATCH] :bug: Fit a copy's masked group to its mask whenever sync changes it A masked group takes all its geometry from its mask. When the mask of a group in a copy authors a flip, the untouched group follows it; a later sync gave the group its main's unflipped geometry, apart from its mask. A masked group whose geometry sync changes in any way carries nothing and takes its mask's geometry again, as a group a sync moves or resizes fits its shapes again. Test: flipping-the-mask-of-a-copy-group-flips-the-group-for-good. The benchmark of the previous commit covers this one. AI-assisted-by: claude-opus-5-5 --- common/src/app/common/logic/libraries.cljc | 13 ++++++++----- .../common_tests/logic/composable_gen_test.cljc | 6 ++++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/common/src/app/common/logic/libraries.cljc b/common/src/app/common/logic/libraries.cljc index 3154612828..ca4ed54434 100644 --- a/common/src/app/common/logic/libraries.cljc +++ b/common/src/app/common/logic/libraries.cljc @@ -683,11 +683,14 @@ ;; a group or bool takes its bounds from its children, which sync places ;; one by one: a move or resize of its bounds carries nothing, and it ;; fits them again - (and (seq ids) (or moved? resized?) - (mth/close? (or (:rotation before) 0) (or (:rotation after) 0) 1e-10) - (= (boolean (:flip-x before)) (boolean (:flip-x after))) - (= (boolean (:flip-y before)) (boolean (:flip-y after))) - (#{:group :bool} (:type before))) + (and (seq ids) + (#{:group :bool} (:type before)) + (or (and (or moved? resized?) + (mth/close? (or (:rotation before) 0) (or (:rotation after) 0) 1e-10) + (= (boolean (:flip-x before)) (boolean (:flip-x after))) + (= (boolean (:flip-y before)) (boolean (:flip-y after)))) + ;; a masked group takes all its geometry from its mask + (:masked-group before))) (let [refit {:type :reg-objects :shapes [(:id before)]}] (pcb/add-changes changes container [refit] [refit])) diff --git a/common/test/common_tests/logic/composable_gen_test.cljc b/common/test/common_tests/logic/composable_gen_test.cljc index ead5e8b0d0..18311a8d96 100644 --- a/common/test/common_tests/logic/composable_gen_test.cljc +++ b/common/test/common_tests/logic/composable_gen_test.cljc @@ -2524,6 +2524,12 @@ :layout-copies false :layout-children false}] :ops [[:structure 0 4] [:transform 0 4 0 2]]})))) +(t/deftest flipping-the-mask-of-a-copy-group-flips-the-group-for-good + (t/is (map? (cg/run {:world [3 1 {:variants true :rich-variants true :text true :layout :grid + :layout-copies false :layout-children false}] + :ops [[:remove-child 9] [:add-child 7] [:delete 7] [:add-child] [:undo] + [:structure 10 1] [:transform 10 5 0 2]]})))) + (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}]