🐛 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
This commit is contained in:
alonso.torres 2026-11-17 01:04:52 +01:00
parent 6bdb5565d8
commit d5cd89adc2
4 changed files with 25 additions and 27 deletions

View File

@ -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`

View File

@ -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))

View File

@ -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,

View File

@ -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]