From fcd9128575280e0b75a9ec079875a6359f4df92b Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Sun, 1 Nov 2026 22:39:42 +0100 Subject: [PATCH] :bug: Leave no override when a shape moved out of a layout loses its margins A copy in a flex main kept its margin type through a reset, since its placement belongs to its position. Nesting it out of the layout cleared its layout-item data, and the relocation marked a margin override, although the copy now matched its main. Clearing layout-item data when a shape leaves a layout is a consequence of the move, not an edit of those attributes, so it marks no override. Benchmark (scripts/bench-components, lower quantile in ms): | world | baseline | now | ratio | |------------------------------------+----------+--------+-------| | deepest-edit-through-three-levels | 35.215 | 18.992 | 0.54 | | edit-through-a-chain-of-dependents | 68.931 | 39.094 | 0.57 | | library-update-into-copies | 83.083 | 46.864 | 0.56 | | main-edit-among-many-shapes | 4.837 | 2.236 | 0.46 | | main-edit-into-10-copies | 1.79 | 0.941 | 0.53 | | main-edit-into-100-copies | 15.415 | 9.524 | 0.62 | | main-edit-into-1000-copies | 153.086 | 95.507 | 0.62 | | variant-switch-into-copies | 32.052 | 22.002 | 0.69 | AI-assisted-by: claude-opus-5-5 --- common/src/app/common/logic/shapes.cljc | 2 +- common/test/common_tests/logic/composable_gen_test.cljc | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/common/src/app/common/logic/shapes.cljc b/common/src/app/common/logic/shapes.cljc index 293a89d3d0..4e6e78b50e 100644 --- a/common/src/app/common/logic/shapes.cljc +++ b/common/src/app/common/logic/shapes.cljc @@ -566,7 +566,7 @@ (-> changes ;; Remove layout-item properties and tokens when moving a shape outside a layout (cond-> (not (ctl/any-layout? parent)) - (-> (pcb/update-shapes ids ctl/remove-layout-item-data) + (-> (pcb/update-shapes ids ctl/remove-layout-item-data {:ignore-touched true}) (pcb/update-shapes ids cto/unapply-layout-item-tokens))) ;; Hide in the viewer the boards moved into a board diff --git a/common/test/common_tests/logic/composable_gen_test.cljc b/common/test/common_tests/logic/composable_gen_test.cljc index 659e694260..dc6a431f96 100644 --- a/common/test/common_tests/logic/composable_gen_test.cljc +++ b/common/test/common_tests/logic/composable_gen_test.cljc @@ -958,3 +958,10 @@ :library-depth 1 :library true :rich-variants true :library-text true :layout-copies true :text true}] :ops [[:rotate 1 0 0 0] [:switch 3 0 0 0]]})))) + +(t/deftest generated-copy-moved-out-of-a-layout-loses-its-margins-without-an-override + ;; a copy whose margin type a reset kept is nested out of its flex parent; + ;; leaving the layout clears its margins, which is no override + (t/is (map? (cg/run {:world [2 1 {:text true :text-styles true :layout :flex :layout-children true}] + :ops [[:remove-child 0 0 0 0] [:nest 0 0 0 0] [:style 2 27 1] + [:edit 0 1 1 :copy-head] [:reset 0] [:nest 0 0 0 0]]}))))