From a7ae3140c5aa834bb7e8f150038e93cb5de06fff Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Mon, 2 Nov 2026 04:17:52 +0100 Subject: [PATCH] :bug: Keep the children of a copy sized on its own when its main fills A nested copy made absolute in a copy keeps its own geometry. Its main was then set to fill a grid and shrank. Sync places the main's children like the copy: it resized the main to the copy's size, but the grid's reflow refilled it to its cell, and the move that lines the two up shifted the copy's children by the difference. The main's subtree is now resized out of its parent's layout, since the copy's size is its own and no layout of the main owns it. Benchmark (scripts/bench-components, lower quantile in ms): | world | baseline | now | ratio | |------------------------------------+----------+---------+-------| | deepest-edit-through-three-levels | 35.215 | 18.99 | 0.54 | | edit-through-a-chain-of-dependents | 68.931 | 37.28 | 0.54 | | library-update-into-copies | 83.083 | 49.96 | 0.60 | | main-edit-among-many-shapes | 4.837 | 2.233 | 0.46 | | main-edit-into-10-copies | 1.79 | 1.017 | 0.57 | | main-edit-into-100-copies | 15.415 | 9.558 | 0.62 | | main-edit-into-1000-copies | 153.086 | 91.362 | 0.60 | | variant-switch-into-copies | 32.052 | 20.725 | 0.65 | AI-assisted-by: claude-opus-5-5 --- common/src/app/common/logic/libraries.cljc | 4 +++- common/test/common_tests/logic/composable_gen_test.cljc | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/common/src/app/common/logic/libraries.cljc b/common/src/app/common/logic/libraries.cljc index b13132985e..c589d9bb70 100644 --- a/common/src/app/common/logic/libraries.cljc +++ b/common/src/app/common/logic/libraries.cljc @@ -569,7 +569,9 @@ objects (let [modif-tree (gm/set-objects-modifiers {(:id shape-main) {:modifiers (ctm/change-size shape-main width height)}} - (reduce-kv #(d/update-when %1 %2 merge %3) objects authored))] + ;; the copy keeps its own size, which no layout of the main owns + (-> (reduce-kv #(d/update-when %1 %2 merge %3) objects authored) + (assoc-in [(:id shape-main) :layout-item-absolute] true)))] (reduce-kv (fn [objects id {:keys [modifiers]}] (d/update-when objects id gsh/transform-shape modifiers)) objects diff --git a/common/test/common_tests/logic/composable_gen_test.cljc b/common/test/common_tests/logic/composable_gen_test.cljc index 1b1d486a93..8c620997ad 100644 --- a/common/test/common_tests/logic/composable_gen_test.cljc +++ b/common/test/common_tests/logic/composable_gen_test.cljc @@ -973,3 +973,10 @@ (t/is (map? (cg/run {:world [2 0 {:variants true :text-styles true :library true :rich-variants true :layout-copies true :text true}] :ops [[:switch 3 0 0 0] [:nest 9 0 0 0] [:edit 7 1 1 :copy-head] [:reset 7]]})))) + +(t/deftest generated-copy-with-its-own-geometry-keeps-children-of-a-main-set-to-fill + ;; a nested copy made absolute in a copy keeps its size when its main is + ;; set to fill a grid; its children stay where the copy has them + (t/is (map? (cg/run {:world [2 2 {:variants true :text-styles true :layout :grid :variant-diff false + :rich-variants true :grid-empty true :layout-copies true :text true}] + :ops [[:style 1 35 1] [:style 0 29 1]]}))))