From 44d13cdd14eacd0eed5a6a1631fdff8404e89bcc Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Sat, 14 Nov 2026 22:46:16 +0100 Subject: [PATCH] :bug: Keep the size of an absolute fill child of a grid A fill child of a grid takes the size of its content, which the grid's fill then fits to its cell. An absolute child is not filled by the grid, and the content of a grid whose flex columns span its width is that width and its padding, so an absolute fill board of a grid grew by its padding at every layout pass and never settled. An absolute child keeps its size. Benchmark (bench-components, run alone): | world | baseline | now | mean | ratio | |------------------------------------+----------+---------+---------+-------| | deepest-edit-through-three-levels | 35.215 | 23.593 | 26.323 | 0.67 | | edit-through-a-chain-of-dependents | 68.931 | 50.077 | 55.477 | 0.73 | | library-update-into-copies | 83.083 | 50.157 | 52.815 | 0.6 | | main-edit-among-many-shapes | 4.837 | 2.511 | 3.077 | 0.52 | | main-edit-into-10-copies | 1.79 | 1.172 | 1.215 | 0.65 | | main-edit-into-100-copies | 15.415 | 9.878 | 12.423 | 0.64 | | main-edit-into-1000-copies | 153.086 | 123.768 | 175.446 | 0.81 | | variant-switch-into-copies | 32.052 | 21.933 | 22.474 | 0.68 | AI-assisted-by: claude-opus-5-5 --- common/src/app/common/geom/modifiers.cljc | 5 ++++- common/test/common_tests/logic/composable_gen_test.cljc | 7 +++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/common/src/app/common/geom/modifiers.cljc b/common/src/app/common/geom/modifiers.cljc index 49cdd21a72..73e1b1874a 100644 --- a/common/src/app/common/geom/modifiers.cljc +++ b/common/src/app/common/geom/modifiers.cljc @@ -223,7 +223,8 @@ "Calculates the modifiers to adjust the bounds for auto-width/auto-height shapes. A fill child of a grid takes the size of its content, unless it is turned in the grid: the grid's fill then sizes it along the grid's - axes, and its content's size counts as its minimum there." + axes, and its content's size counts as its minimum there. An absolute + child keeps its size: the grid does not fill it." [objects bounds parent] (let [parent-id (:id parent) parent-bounds (get bounds parent-id) @@ -250,7 +251,9 @@ (remove ctl/position-absolute?) (remove gco/invalid-geometry?)) + ;; an absolute child is neither placed nor filled by the grid grid-fill? (and (ctl/grid-layout? objects (:parent-id parent)) + (not (ctl/position-absolute? parent)) (not (turned-in-parent? objects bounds parent-id))) auto? (or (ctl/auto? parent) (and grid-fill? (ctl/fill? parent))) diff --git a/common/test/common_tests/logic/composable_gen_test.cljc b/common/test/common_tests/logic/composable_gen_test.cljc index 5832bfb712..ea50fc6e49 100644 --- a/common/test/common_tests/logic/composable_gen_test.cljc +++ b/common/test/common_tests/logic/composable_gen_test.cljc @@ -4308,6 +4308,13 @@ :grid-empty false :layout-copies false :text true}] :ops [[:switch 11] [:switch 5] [:nest 17] [:add-child 15] [:rotate 15] [:style 12 9 1] [:paste 12]]})))) +(t/deftest generated-an-absolute-fill-board-in-a-grid-keeps-its-size + ;; a grid board set to fill a grid cell and then made absolute is no longer + ;; filled by that grid: its layout settles at its size + (t/is (map? (cg/run {:world [2 1 {:variants true :text-styles true :layout :grid :library true + :rich-variants true :layout-children true :layout-copies true :text true}] + :ops [[:remove-child 5 0 0 0] [:style 2 29 1] [:style 5 35 1]]})))) + (t/deftest generated-an-ungroup-gives-a-grid-copy-with-its-own-cells-its-main-tracks ;; a grid copy with its own cells and direction but its main's tracks ;; takes the tracks an ungroup in the main adds before placing the shapes