From d5cd89adc24ae8057a46399406a790d13a922b4d Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Tue, 17 Nov 2026 01:04:52 +0100 Subject: [PATCH] :bug: Keep the places a layout update gives copy shapes A layout update applied its modifiers and then settled the placement of the copy shapes they moved, as a transform does. For a swapped head turned with its main and filling a row, the settle gave back the unskewed turn of its main and undid the skew the layout gives it, which its main keeps (F441: a swapped head turned to fill takes the skew of its main). A layout update no longer settles placement (`apply-modifiers` and `apply-wasm-modifiers` take `:settle-component-placement? false`); a transform still does. The composable model's reflow, which settled placement since `bac1443729` to match the old update, no longer does: with it, layout and settle undid each other and never settled. Test: frontend generated `generated-a-turned-fill-swap-keeps-the-skew-its-row-gives`. ClojureScript only; the benchmark covers JVM code and is not run. AI-assisted-by: claude-opus-5-5 --- .../test_helpers/composable/comp/nodes.cljc | 35 ++++++++----------- .../app/main/data/workspace/modifiers.cljs | 4 +-- .../app/main/data/workspace/shape_layout.cljs | 9 +++-- .../composable_tests/generated_test.cljs | 4 +-- 4 files changed, 25 insertions(+), 27 deletions(-) diff --git a/common/src/app/common/test_helpers/composable/comp/nodes.cljc b/common/src/app/common/test_helpers/composable/comp/nodes.cljc index 2adba4e67d..8e59a7bdda 100644 --- a/common/src/app/common/test_helpers/composable/comp/nodes.cljc +++ b/common/src/app/common/test_helpers/composable/comp/nodes.cljc @@ -183,27 +183,22 @@ (::layout-reflow? changes)) (defn get-layout-reflow-changes - "Derived layout changes on the current file's pages, after copy inputs sync. - As the frontend's layout update applies them, the copy shapes they move - then settle their placement." + "Derived layout changes on the current file's pages, after copy inputs sync." [situation] - (let [file (tm/file situation)] - (reduce (fn [changes [_ page]] - (let [ids (into [] (keep #(when (:layout %) (:id %))) (vals (:objects page)))] - (if (empty? ids) - changes - (let [tree (gm/set-objects-modifiers - (into {} (map #(vector % {:modifiers (ctm/reflow-modifiers)})) ids) - (:objects page)) - next (-> (cls/generate-update-shapes - (pcb/empty-changes nil (:id page)) (keys tree) - (clp/modifiers-transform tree) (:objects page) - {:ignore-touched true :attrs clp/transform-attrs}) - (cll/generate-sync-transformed-placement file (cf/libraries situation) - page (:objects page) (keys tree)))] - (pcb/concat-changes changes next))))) - (pcb/empty-changes) - (get-in file [:data :pages-index])))) + (reduce (fn [changes [_ page]] + (let [ids (into [] (keep #(when (:layout %) (:id %))) (vals (:objects page)))] + (if (empty? ids) + changes + (let [tree (gm/set-objects-modifiers + (into {} (map #(vector % {:modifiers (ctm/reflow-modifiers)})) ids) + (:objects page)) + next (cls/generate-update-shapes + (pcb/empty-changes nil (:id page)) (keys tree) + (clp/modifiers-transform tree) (:objects page) + {:ignore-touched true :attrs clp/transform-attrs})] + (pcb/concat-changes changes next))))) + (pcb/empty-changes) + (get-in (tm/file situation) [:data :pages-index]))) (def ^:private sidebar-layout-child-properties "The properties the sidebar edits as a layout child (`update-layout-child` diff --git a/frontend/src/app/main/data/workspace/modifiers.cljs b/frontend/src/app/main/data/workspace/modifiers.cljs index 46edafdfa6..d8bf3fd4a1 100644 --- a/frontend/src/app/main/data/workspace/modifiers.cljs +++ b/frontend/src/app/main/data/workspace/modifiers.cljs @@ -724,7 +724,7 @@ (assoc :undo-group undo-group) (assoc :reg-objects? true) (assoc :ignore-tree ignore-tree) - (assoc :settle-component-placement? true) + (update :settle-component-placement? #(if (some? %) % true)) (assoc :translation? translation?) ;; Attributes that can change in the transform. This ;; way we don't have to check all the attributes @@ -860,7 +860,7 @@ (assoc :undo-group undo-group) (assoc :reg-objects? true) (assoc :ignore-tree ignore-tree) - (assoc :settle-component-placement? true) + (update :settle-component-placement? #(if (some? %) % true)) ;; Attributes that can change in the transform. This ;; way we don't have to check all the attributes (assoc :attrs clp/transform-attrs)) diff --git a/frontend/src/app/main/data/workspace/shape_layout.cljs b/frontend/src/app/main/data/workspace/shape_layout.cljs index 64132868e6..ff1bea344a 100644 --- a/frontend/src/app/main/data/workspace/shape_layout.cljs +++ b/frontend/src/app/main/data/workspace/shape_layout.cljs @@ -64,19 +64,22 @@ (if (d/not-empty? ids) (let [modif-tree (dwm/create-modif-tree ids (ctm/reflow-modifiers))] ;; the reflow stacks on the latest undo entry, which a - ;; transaction of its own would not + ;; transaction of its own would not; the layout owns the + ;; places it gives, which no placement settle undoes (if (features/active-feature? state "render-wasm/v1") (rx/of (dwm/apply-wasm-modifiers modif-tree :stack-undo? true :undo-transation? false :undo-group undo-group - :ignore-touched true)) + :ignore-touched true + :settle-component-placement? false)) (rx/of (dwm/apply-modifiers {:page-id page-id :modifiers modif-tree :stack-undo? true :undo-transation? false :ignore-touched true - :undo-group undo-group})))) + :undo-group undo-group + :settle-component-placement? false})))) (rx/empty)) ;; The apply events above are dispatched and applied synchronously, diff --git a/frontend/test/frontend_tests/composable_tests/generated_test.cljs b/frontend/test/frontend_tests/composable_tests/generated_test.cljs index 16ffdfa3ea..7f0bada4cd 100644 --- a/frontend/test/frontend_tests/composable_tests/generated_test.cljs +++ b/frontend/test/frontend_tests/composable_tests/generated_test.cljs @@ -1126,9 +1126,9 @@ :layout-children false :grid-empty false :layout-copies true :text true}] :ops [[:rotate 7 0 0 0] [:update-main 0 0 0 0] [:make-variant 19 0 0 0] [:style 0 29 4 0]]}))) -(t/deftest ^:async generated-a-turned-fill-swap-settles-like-its-main-after-the-layout +(t/deftest ^:async generated-a-turned-fill-swap-keeps-the-skew-its-row-gives ;; the layout of a row fills a swapped head turned with its main, which - ;; then settles its placement as the main's + ;; keeps the skew the layout gives it, as its main does (await (replay {:world [2 2 {:variants true :layout :flex :rich-variants true :layout-copies true :text true}] :ops [[:delete 0] [:restore 0] [:add-variant 0 0 0 0] [:swap 6 0 0 0] [:combine 5 0 0 0] [:delete 12 0 0 0] [:combine 9 0 0 0] [:nest 0 0 0 0] [:restore 0 0 0 0] [:combine 8]