diff --git a/common/src/app/common/logic/libraries.cljc b/common/src/app/common/logic/libraries.cljc index 87f6720669..bee71b33a1 100644 --- a/common/src/app/common/logic/libraries.cljc +++ b/common/src/app/common/logic/libraries.cljc @@ -1762,15 +1762,19 @@ (defn add-update-attr-changes "Add to `changes` the operations of `attr-operations` on `dest-shape`, and - the update of its parents." + the update of its parents. The undo fits the shape itself too, when it is a + group or bool: its children are undone before it, while it keeps the + transform the change gave it." [changes dest-shape container roperations uoperations] (let [update-parents {:type :reg-objects - :shapes (cfh/get-parent-ids (:objects container) (:id dest-shape))}] + :shapes (cfh/get-parent-ids (:objects container) (:id dest-shape))} + update-self {:type :reg-objects + :shapes [(:id dest-shape)]}] (pcb/add-changes changes container [{:type :mod-obj :id (:id dest-shape) :operations roperations} update-parents] - ;; undone as the shape first, then its parents - [update-parents + ;; undone as the shape first, then itself and its parents + [update-self {:type :mod-obj :id (:id dest-shape) :operations (vec uoperations)}]))) diff --git a/common/test/common_tests/logic/composable_gen_test.cljc b/common/test/common_tests/logic/composable_gen_test.cljc index 12bffa323e..3b7f7d9788 100644 --- a/common/test/common_tests/logic/composable_gen_test.cljc +++ b/common/test/common_tests/logic/composable_gen_test.cljc @@ -2497,6 +2497,11 @@ :layout-copies false :layout-children false}] :ops [[:add-child 1] [:structure 2] [:transform 2 2 0 2]]})))) +(t/deftest undoing-an-update-main-that-turns-a-group-gives-the-group-its-size-back + (t/is (map? (cg/run {:world [2 0 {:variants true :rich-variants true :text false :layout :flex + :layout-copies false :layout-children true}] + :ops [[:rotate] [:add-child] [:structure 17] [:update-main]]})))) + (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}]