From 4eb537b3f7f32b18160e2b5c914646ccb9c48d05 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Mon, 16 Nov 2026 00:51:23 +0100 Subject: [PATCH] :bug: Combine a bool's shapes again after ungrouping inside it A bool whose only child was a group kept, after ungrouping that group, the content it had made of the group: the outlines of its shapes one after the other, not the boolean result of them. The next refit of the bool, such as the undo of a later edit of one of its shapes, recomputed it, so that undo did not give back the state before the edit. An ungroup now refits the group or bool around the ungrouped shape, with the undo values of the refit. Tests: `groups-test/ungrouping-a-group-in-a-bool-combines-its-shapes-again` (fails before the fix), generated `an-ungroup-in-a-bool-combines-its-shapes-again`. The ungroup is outside the paths the component benchmark measures; it is not run. AI-assisted-by: claude-opus-5-5 --- common/src/app/common/logic/groups.cljc | 8 ++++++-- .../logic/composable_gen_test.cljc | 8 ++++++++ .../test/common_tests/logic/groups_test.cljc | 19 +++++++++++++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/common/src/app/common/logic/groups.cljc b/common/src/app/common/logic/groups.cljc index 850545317a..0a6792b4b6 100644 --- a/common/src/app/common/logic/groups.cljc +++ b/common/src/app/common/logic/groups.cljc @@ -163,7 +163,9 @@ (-> (pcb/empty-changes it page-id) (pcb/with-objects objects) (pcb/change-parent parent-id children index-in-parent options) - (pcb/remove-objects [(:id group)] options))))) + (pcb/remove-objects [(:id group)] options) + ;; a group or bool around takes the shapes as they now are + (pcb/resize-parents [parent-id]))))) (defn remove-frame-changes ([it page-id frame objects] @@ -182,7 +184,9 @@ (cond-> (ctl/any-layout? frame) (pcb/update-shapes (:shapes frame) ctl/remove-layout-item-data (select-keys options [:ignore-touched]))) (pcb/change-parent parent-id children idx-in-parent options) - (pcb/remove-objects [(:id frame)] options))))) + (pcb/remove-objects [(:id frame)] options) + ;; a group or bool around takes the shapes as they now are + (pcb/resize-parents [parent-id]))))) (defn ungroup-ids "The shapes of `ids` an ungroup takes apart: not inside a copy, not a diff --git a/common/test/common_tests/logic/composable_gen_test.cljc b/common/test/common_tests/logic/composable_gen_test.cljc index 276ff6722b..21acba9213 100644 --- a/common/test/common_tests/logic/composable_gen_test.cljc +++ b/common/test/common_tests/logic/composable_gen_test.cljc @@ -2469,6 +2469,14 @@ :layout-copies false}] :ops [[:transform 0 10 0 8] [:apply-token 12 11] [:style 12 3 0 1] [:token-value 0 2]]})))) +(t/deftest an-ungroup-in-a-bool-combines-its-shapes-again + ;; ungrouping the group a bool combines makes the bool combine its shapes, + ;; so undoing a later edit gives the state before it + (t/is (map? (cg/run {:world [2 0 {:variants true :rich-variants true :text true :layout nil :layout-copies true + :layout-children false}] + :ops [[:delete 3 0 0 0] [:structure 3 0 7 0] [:add-child 2] [:structure 2 5 0] [:delete 2] + [:restore 2] [:swap 2 0 0 0] [:structure 3 2 0 0] [:text-style 2 0 1]]})))) + (t/deftest a-switched-head-in-a-copy-scales-with-its-parent ;; the head authors the size the switch carried, which its copy parent's ;; later resize scales through its constraint diff --git a/common/test/common_tests/logic/groups_test.cljc b/common/test/common_tests/logic/groups_test.cljc index 61d0936600..80aa930627 100644 --- a/common/test/common_tests/logic/groups_test.cljc +++ b/common/test/common_tests/logic/groups_test.cljc @@ -156,3 +156,22 @@ objects (objects (thf/apply-changes file changes))] (t/is (= (-> (get objects (:id shape)) :selrect ((juxt :x :y :width :height))) (-> (get objects id) :selrect ((juxt :x :y :width :height))))))) + +(t/deftest ungrouping-a-group-in-a-bool-combines-its-shapes-again + (let [file (-> (thf/sample-file :file1) + (ths/add-sample-shape :rect-a :width 50 :height 50) + (ths/add-sample-shape :rect-b :width 70 :height 25)) + page (thf/current-page file) + ;; the bool its shapes make without the group + [direct changes] (clb/generate-create-bool nil (:id page) (:objects page) + [(thi/id :rect-a) (thi/id :rect-b)] :difference nil) + expected (:content (get (objects (thf/apply-changes file changes)) (:id direct))) + [id file] (group file [:rect-a :rect-b]) + page (thf/current-page file) + [shape changes] (clb/generate-create-bool nil (:id page) (:objects page) [id] :difference nil) + file (thf/apply-changes file changes) + page (thf/current-page file) + file (thf/apply-changes file (clg/generate-ungroup-changes nil (:id page) (:objects page) [id])) + bool (get (objects file) (:id shape))] + (t/is (= #{(thi/id :rect-a) (thi/id :rect-b)} (set (:shapes bool)))) + (t/is (= (str expected) (str (:content bool))))))