diff --git a/common/src/app/common/logic/libraries.cljc b/common/src/app/common/logic/libraries.cljc index 3aaf881e95..824a459bea 100644 --- a/common/src/app/common/logic/libraries.cljc +++ b/common/src/app/common/logic/libraries.cljc @@ -1181,9 +1181,13 @@ (and keep-name? (ctk/touched-group? shape-inst :name-group)) (conj :name-group)))) ;; A previous update is not a reset of the main's authored - ;; overrides. Repeating it must retain the groups it pushed. + ;; overrides. Repeating it must retain the groups it pushed, + ;; and a main that is itself a copy authors the sizing the + ;; push fixes. (set-touched shape-main main-container - (set/union (:touched shape-main) (set/difference inst-touched kept-items)))) + (cond-> (set/union (:touched shape-main) (set/difference inst-touched kept-items)) + (:shape-ref shape-main) + (into (map #(ctk/resolve-sync-group (:type shape-main) %)) (keys fixed))))) (ctsl/any-layout? shape-main) (update-layout-children main-container shape-main shape-inst #(ctf/get-shape-in-copy container % shape-inst) false) diff --git a/common/src/app/common/test_helpers/composable/shadow.cljc b/common/src/app/common/test_helpers/composable/shadow.cljc index b5bfe7a003..16e0c1e4da 100644 --- a/common/src/app/common/test_helpers/composable/shadow.cljc +++ b/common/src/app/common/test_helpers/composable/shadow.cljc @@ -612,6 +612,16 @@ (update id merge kept-items) kept-name (assoc-in [id :name-group] kept-name) + ;; a main that is itself a copy authors the layout sizing a + ;; pushed geometry fixes on it, which keeps the pushed size + (and (:shape-ref ref) (contains? groups :geometry-group)) + (update (:id ref) merge + (into {} + (keep (fn [group] + (when (not= (get (get before (:id ref)) group) (get ref group)) + [group (values ref group)]))) + [:layout-item-h-sizing :layout-item-v-sizing])) + (and (:shape-ref ref) (seq groups)) (update (:id ref) (fn [main-groups] diff --git a/common/test/common_tests/logic/composable_gen_test.cljc b/common/test/common_tests/logic/composable_gen_test.cljc index ca1569a95f..20a9a31ac6 100644 --- a/common/test/common_tests/logic/composable_gen_test.cljc +++ b/common/test/common_tests/logic/composable_gen_test.cljc @@ -4469,3 +4469,8 @@ :layout-copies true :layout-children false}] :ops [[:remove-child 0 0 0 0] [:add-child 1] [:structure 0 4 0] [:transform 0 16 0 3] [:rotate 0 0 0 0] [:rotate 1 0 0 0]]})))) + +(t/deftest generated-an-update-main-into-a-nested-copy-authors-the-sizing-it-fixes + ;; a copy child filling a row pushes a transform into the nested copy its + ;; main holds, which takes it with its sizing fixed as its own override + (t/is (map? (cg/run {:world [3 2 {:text true :layout :flex}] :ops [[:nest 24 11 9 6] [:delete 1] [:restore 1] [:add-child 15 16 4 29] [:move 23 24 12 20] [:edit 25 25 27 25] [:undo 23 17 15 25] [:style 23 29 25 20] [:transform 29 11 7 27] [:update-main 2 19 2 29]]})))) diff --git a/frontend/test/frontend_tests/composable_tests/generated_test.cljs b/frontend/test/frontend_tests/composable_tests/generated_test.cljs index 7f0bada4cd..e3b3ee122d 100644 --- a/frontend/test/frontend_tests/composable_tests/generated_test.cljs +++ b/frontend/test/frontend_tests/composable_tests/generated_test.cljs @@ -1191,3 +1191,8 @@ (pr-str (merge-with - (select-keys after [:pass :fail :error]) (select-keys before [:pass :fail :error])))))) (recur (inc index))))))) + +(t/deftest ^:async generated-an-update-main-into-a-nested-copy-authors-the-sizing-it-fixes + ;; a copy child filling a row pushes a transform into the nested copy its + ;; main holds, which takes it with its sizing fixed as its own override + (await (replay {:world [3 2 {:text true :layout :flex}] :ops [[:nest 24 11 9 6] [:delete 1] [:restore 1] [:add-child 15 16 4 29] [:move 23 24 12 20] [:edit 25 25 27 25] [:undo 23 17 15 25] [:style 23 29 25 20] [:transform 29 11 7 27] [:update-main 2 19 2 29]]})))