diff --git a/common/src/app/common/test_helpers/composable/gen.cljc b/common/src/app/common/test_helpers/composable/gen.cljc index 0770fc7166..5e8d512587 100644 --- a/common/src/app/common/test_helpers/composable/gen.cljc +++ b/common/src/app/common/test_helpers/composable/gen.cljc @@ -388,9 +388,11 @@ (not (ctk/main-instance? shape)) (some ctk/main-instance? (cfh/get-parents objects (:id shape)))) ;; the model places the children of a group in a - ;; copy only as far as the group's board lets it + ;; copy through the board around it, and only when + ;; no layout places that group 2 (and (:shape-ref shape) (nil? (:component-id shape)) - (not (#{:group :bool} (:type (get objects (:parent-id shape)))))) + (or (not (#{:group :bool} (:type (get objects (:parent-id shape))))) + (not (ctl/any-layout? (get objects (:frame-id shape)))))) 3 (and (copy-head shape) (not (top-copy shape))) 4 (top-copy shape))) (:text :text-style) (= :text (:type shape)) diff --git a/common/src/app/common/test_helpers/composable/oracle.cljc b/common/src/app/common/test_helpers/composable/oracle.cljc index 9174bef268..6060d348f3 100644 --- a/common/src/app/common/test_helpers/composable/oracle.cljc +++ b/common/src/app/common/test_helpers/composable/oracle.cljc @@ -433,12 +433,17 @@ (d/without-nils (select-keys shape [:constraints-h :constraints-v])))) main-parent (get main-objects (:parent-id main)) ;; a group or bool takes its bounds and turn from its children, - ;; so they take their place from the board around it - board? (and (#{:group :bool} (:type parent)) main-parent - (#{:group :bool} (:type main-parent)) - (not (ctl/any-layout? (get objects (:frame-id shape))))) - parent (if board? (get objects (:frame-id shape)) parent) - main-parent (if board? (get main-objects (:frame-id main)) main-parent) + ;; so they take their place from the board around it, or from + ;; the nearest group or bool on the way that authors its geometry + [parent main-parent] + (if (ctl/any-layout? (get objects (:frame-id shape))) + [parent main-parent] + (loop [parent parent main-parent main-parent] + (if (and (#{:group :bool} (:type parent)) + (#{:group :bool} (:type main-parent)) + (not (contains? (:touched parent) :geometry-group))) + (recur (get objects (:parent-id parent)) (get main-objects (:parent-id main-parent))) + [parent main-parent]))) ;; a reset refreshes its subtree from the loaded library while ;; the parent keeps the version it accepted, which may lack a turn; ;; a swapped parent holds the child in the main of its content @@ -838,7 +843,8 @@ :let [group (some (fn [[group candidate]] (when (= unit candidate) group)) shadow/text-groups)] :when (not (contains? touched group))] (fail :I4 {:shape (:name shape) :group group :unit unit}))))) - (when-not (contains? touched :geometry-group) + ;; a group or bool takes its bounds from its children, which are checked + (when-not (or (contains? touched :geometry-group) (#{:group :bool} (:type shape))) (let [expected (expected-geometry file container libraries shape #(cf/reference-libraries situation %)) attrs (cond-> (geometry-differences (:objects page) shape expected) diff --git a/common/test/common_tests/logic/composable_gen_test.cljc b/common/test/common_tests/logic/composable_gen_test.cljc index dc362184b2..12bffa323e 100644 --- a/common/test/common_tests/logic/composable_gen_test.cljc +++ b/common/test/common_tests/logic/composable_gen_test.cljc @@ -2477,21 +2477,26 @@ :layout-copies false :layout-children true}] :ops [[:add-child 5] [:structure 12] [:transform 12 10 0 12]]})))) +(t/deftest the-shapes-of-a-moved-copy-group-follow-it + (t/is (map? (cg/run {:world [2 0 {:variants false :rich-variants false :text false :layout :flex + :layout-copies false :layout-children true}] + :ops [[:add-child] [:structure 9] [:transform 10 0 0 12]]})))) + (t/deftest syncing-a-copy-group-keeps-the-place-its-shape-authors (t/is (map? (cg/run {:world [1 0 {:variants true :rich-variants false :text false :layout :grid :layout-copies false :layout-children false}] :ops [[:add-child 1] [:structure 2] [:transform 2 0 0 2]]})))) -(t/deftest syncing-a-copy-group-keeps-the-size-its-shape-authors - (t/is (map? (cg/run {:world [1 0 {:variants true :rich-variants false :text false :layout :grid - :layout-copies false :layout-children false}] - :ops [[:add-child 1] [:structure 2] [:transform 2 2 0 2]]})))) - (t/deftest undoing-a-turn-of-a-copy-group-gives-the-groups-of-its-copies-their-bounds-back (t/is (map? (cg/run {:world [2 2 {:variants true :rich-variants true :text true :layout nil :layout-copies false :layout-children false}] :ops [[:add-child 7] [:add-child 7] [:structure 13] [:transform 10 15 0 12]]})))) +(t/deftest syncing-a-copy-group-keeps-the-size-its-shape-authors + (t/is (map? (cg/run {:world [1 0 {:variants true :rich-variants false :text false :layout :grid + :layout-copies false :layout-children false}] + :ops [[:add-child 1] [:structure 2] [:transform 2 2 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}] diff --git a/frontend/test/frontend_tests/composable_tests/interpreter.cljs b/frontend/test/frontend_tests/composable_tests/interpreter.cljs index 38f77e701e..5988be7f10 100644 --- a/frontend/test/frontend_tests/composable_tests/interpreter.cljs +++ b/frontend/test/frontend_tests/composable_tests/interpreter.cljs @@ -29,6 +29,7 @@ [app.common.test-helpers.ids-map :as cthi] [app.common.test-helpers.shapes :as cths] [app.common.types.shape :as cts] + [app.common.types.tokens-lib :as ctob] [app.common.uuid :as uuid] [app.main.data.changes :as dch] [app.main.data.workspace :as dw] @@ -40,6 +41,8 @@ [app.main.data.workspace.texts :as dwtx] [app.main.data.workspace.thumbnails :as dwth] [app.main.data.workspace.tokens.application :as dwta] + [app.main.data.workspace.tokens.library-edit :as dwtl] + [app.main.data.workspace.tokens.propagation :as dwtp] [app.main.data.workspace.transforms :as dwt] [app.main.data.workspace.undo :as dwu] [app.main.data.workspace.variants :as dwv] @@ -257,6 +260,15 @@ :token token :on-update-shape dwta/update-shape-radius})]) + (instance? n/EditTokenValue op) + ;; as the token form commits an edit: the token, then its propagation + (let [data (:data (current-file)) + lib (cfo/get-tokens-lib data) + token-set (ctob/get-set-by-name lib "composable") + token (ctob/get-token-by-name lib "composable" (:token-name op))] + [(dwtl/update-token (ctob/get-id token-set) (:id token) {:value (:value op)}) + (dwtp/propagate-workspace-tokens)]) + (instance? n/UnapplyToken op) [(dwta/unapply-token {:shape-ids [(tm/target-shape-id situation (:target op))] :attributes n/radius-attrs