📎 Lay out the parents of deleted and restored components

The pure runner's delete and restore of a component left the layouts
around the main untouched, while the frontend lays out the parents of
the deleted main and the frames the restored shapes go into. In a
variant set, a flex board, a restored member then kept a place the
layout would not give it, and the next edit's layout pass moved it, so a
move of a shape inside it landed off the requested offset. Both
operations now reflow those layouts.

Harness only; the benchmark is not run.

AI-assisted-by: claude-opus-5-5
This commit is contained in:
alonso.torres 2026-11-08 02:58:23 +01:00
parent fb00559613
commit db512c2dc9
2 changed files with 17 additions and 6 deletions

View File

@ -1058,12 +1058,13 @@
root-id (tm/target-shape-id situation target)
page (thf/current-page the-file)
component-id (:component-id (get (:objects page) root-id))
[_ changes] (cls/generate-delete-shapes (pcb/empty-changes nil (:id page))
(:data the-file)
page
(:objects page)
#{root-id}
{})
[all-parents changes] (cls/generate-delete-shapes (pcb/empty-changes nil (:id page))
(:data the-file)
page
(:objects page)
#{root-id}
{})
changes (with-layouts-reflow changes all-parents)
file' (thf/apply-changes the-file changes :validate? false)]
(-> situation
(tm/with-file file')
@ -1114,6 +1115,8 @@
(:id the-file)
page
(:objects page))
;; the frontend lays out the frames the restored shapes go into
changes (with-layouts-reflow changes (keep :frame-id (:redo-changes changes)))
file' (thf/apply-changes the-file changes :validate? false)]
(-> situation
(tm/with-file file')

View File

@ -1749,6 +1749,14 @@
:grid-empty false :layout-copies true :text true}]
:ops [[:swap 0 0 0 0] [:library-add-variant 0 0 0 0] [:library-sync] [:switch 0]]}))))
(t/deftest moving-a-shape-in-a-restored-library-variant-moves-it-by-the-requested-offset
(t/is (map? (cg/run {:world [2 0 {:variants true :text-styles true :library-variants true :stale-libraries true
:layout nil :layout-item-margins false :grid-square false :library-depth 1
:library true :rich-variants true :layout-children false :library-text true
:grid-empty false :layout-copies true :text true}]
:ops [[:library-make-variant 0] [:library-sync] [:switch 0] [:library-delete 1]
[:library-sync] [:library-restore 1] [:library-sync] [:library-transform 0 0 4 1]]}))))
(t/deftest switching-a-copy-keeps-the-layout-item-overrides-of-its-children
(t/is (map? (cg/run {:world [3 2 {:variants true :text-styles true :layout :grid :variant-diff false
:layout-item-margins false :grid-square false :rich-variants true