From 9664a1ecc68723242989bb729ea3c0b4457ba1ec Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Sun, 1 Nov 2026 02:09:49 +0100 Subject: [PATCH] :bug: Give a reset head back its grid cell when it leaves absolute A reset clears a copy head's own layout item values after its sync, so a head made absolute in the copy came back into its parent grid's flow after the cells had been assigned, and its cell stayed empty until a full sync. The reset now assigns its grid parent's cells again at its end. Benchmark (scripts/bench-components, ms, lower 2.5% quantile): | world | baseline | now | ratio | |------------------------------------+----------+--------+-------| | deepest-edit-through-three-levels | 35.215 | 18.5 | 0.53 | | edit-through-a-chain-of-dependents | 68.931 | 36.37 | 0.53 | | library-update-into-copies | 83.083 | 44.588 | 0.54 | | main-edit-among-many-shapes | 4.837 | 2.03 | 0.42 | | main-edit-into-10-copies | 1.79 | 0.953 | 0.53 | | main-edit-into-100-copies | 15.415 | 9.2 | 0.6 | | main-edit-into-1000-copies | 153.086 | 91.647 | 0.6 | | variant-switch-into-copies | 32.052 | 20.181 | 0.63 | AI-assisted-by: claude-opus-5-5 --- common/src/app/common/logic/libraries.cljc | 7 +++++-- common/test/common_tests/logic/composable_gen_test.cljc | 8 ++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/common/src/app/common/logic/libraries.cljc b/common/src/app/common/logic/libraries.cljc index 35dc408308..68537a7c58 100644 --- a/common/src/app/common/logic/libraries.cljc +++ b/common/src/app/common/logic/libraries.cljc @@ -2068,11 +2068,14 @@ (defn generate-reset-component "Reset the copy head to its near main. A swapped head turns back into the component of the main shape it refers to, keeping its id. A nested head - also takes its position's placement and inherited layout item values." + also takes its position's placement and inherited layout item values, + and its grid parent's cells follow when that takes it in or out of the + flow." [changes file-full libraries container id] (-> changes (pcb/with-container container) (pcb/with-objects (:objects container)) (generate-sync-shape-direct file-full libraries container id true) (settle-reset-placement file-full libraries container id) - (reset-layout-item file-full libraries container id))) + (reset-layout-item file-full libraries container id) + (reassign-parent-grid-cells container id))) diff --git a/common/test/common_tests/logic/composable_gen_test.cljc b/common/test/common_tests/logic/composable_gen_test.cljc index 086b3e8852..a079bdf4f5 100644 --- a/common/test/common_tests/logic/composable_gen_test.cljc +++ b/common/test/common_tests/logic/composable_gen_test.cljc @@ -881,3 +881,11 @@ (t/is (map? (cg/run {:world [2 2 {:variants true :text-styles true :layout :flex :library true :rich-variants true :layout-copies true :text true}] :ops [[:transform 7 0 0 8] [:delete 0] [:restore 0] [:add-child 9 0 0 0]]})))) + +(t/deftest generated-reset-of-an-absolute-grid-head-gives-it-back-its-cell + ;; a copy makes a nested head absolute and authors its grid's cells; the + ;; reset takes the head back into the flow and into a cell + (t/is (map? (cg/run {:world [2 1 {:variants true :text-styles true :library-variants true :stale-libraries true + :layout :grid :library-depth 1 :library true :rich-variants true + :layout-children true :library-text true :layout-copies true :text true}] + :ops [[:style 11 35 1] [:grid-direction 13 0 0 1] [:grid-cell 13 0 0 1] [:reset 14 0 0 0]]}))))