From db512c2dc9eb9b161cb64cb7ec06fe2b04463d91 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Sun, 8 Nov 2026 02:58:23 +0100 Subject: [PATCH] :paperclip: 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 --- .../test_helpers/composable/comp/nodes.cljc | 15 +++++++++------ .../common_tests/logic/composable_gen_test.cljc | 8 ++++++++ 2 files changed, 17 insertions(+), 6 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 db2414a814..2fd6686531 100644 --- a/common/src/app/common/test_helpers/composable/comp/nodes.cljc +++ b/common/src/app/common/test_helpers/composable/comp/nodes.cljc @@ -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') diff --git a/common/test/common_tests/logic/composable_gen_test.cljc b/common/test/common_tests/logic/composable_gen_test.cljc index 858751b5c4..28faf9e86f 100644 --- a/common/test/common_tests/logic/composable_gen_test.cljc +++ b/common/test/common_tests/logic/composable_gen_test.cljc @@ -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