From 88ac0cbe3b189b4f1c0e021f5ef0b7261ea4735f Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Thu, 12 Nov 2026 01:32:57 +0100 Subject: [PATCH] :bug: Lay out a grid auto track that has no value on the JVM The track editor stores an auto track as {:type :auto :value nil}. The grid layout summed the flex fractions with (max 1 value) over every track, which throws on the JVM for a nil value; JavaScript's Math.max(1, null) is 1, so only the frontend laid such a grid out. Only a flex track counts its value now, at least one fraction. Test: grid-layout-data-takes-an-auto-track-without-a-value (found by the new grid gate, which adds an auto row). Focused: geom-grid-layout-test, 21 tests, 0 failures; the full common suite runs at the end of this series. Benchmark (scripts/bench-components, ms, lower 2.5% quantile), measured with the other production changes of this series in the tree; none of them is on a measured path: | :world | :baseline | :now | :mean | :ratio | |------------------------------------+-----------+---------+---------+--------| | deepest-edit-through-three-levels | 35.215 | 22.167 | 22.682 | 0.63 | | edit-through-a-chain-of-dependents | 68.931 | 43.218 | 44.696 | 0.63 | | library-update-into-copies | 83.083 | 47.824 | 50.506 | 0.58 | | main-edit-among-many-shapes | 4.837 | 2.216 | 2.34 | 0.46 | | main-edit-into-10-copies | 1.79 | 1.067 | 1.133 | 0.6 | | main-edit-into-100-copies | 15.415 | 10.604 | 10.813 | 0.69 | | main-edit-into-1000-copies | 153.086 | 106.085 | 108.631 | 0.69 | | variant-switch-into-copies | 32.052 | 22.556 | 23.137 | 0.7 | AI-assisted-by: claude-opus-5-5 --- .../app/common/geom/shapes/grid_layout/layout_data.cljc | 8 ++++---- common/test/common_tests/geom_grid_layout_test.cljc | 6 ++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/common/src/app/common/geom/shapes/grid_layout/layout_data.cljc b/common/src/app/common/geom/shapes/grid_layout/layout_data.cljc index 1dd7524f40..d089faff2d 100644 --- a/common/src/app/common/geom/shapes/grid_layout/layout_data.cljc +++ b/common/src/app/common/geom/shapes/grid_layout/layout_data.cljc @@ -122,10 +122,10 @@ [track-list] (let [calc-tracks-total-frs (fn [acc {:keys [type value]}] - (let [value (max 1 value)] - (cond-> acc - (= type :flex) - (+ value))))] + ;; only a flex track counts its value, at least one fraction + (cond-> acc + (= type :flex) + (+ (max 1 (or value 0)))))] (->> track-list (reduce calc-tracks-total-frs 0)))) (defn tracks-total-autos diff --git a/common/test/common_tests/geom_grid_layout_test.cljc b/common/test/common_tests/geom_grid_layout_test.cljc index 1ba115d73d..2041f187a6 100644 --- a/common/test/common_tests/geom_grid_layout_test.cljc +++ b/common/test/common_tests/geom_grid_layout_test.cljc @@ -166,6 +166,12 @@ (t/is (mth/close? 5 (:column-gap result))) (t/is (mth/close? 7 (:row-gap result))))) +(t/deftest grid-layout-data-takes-an-auto-track-without-a-value + ;; the track editor stores an auto track with no value + (let [frame (make-grid-frame :layout-grid-rows [{:type :auto :value nil}]) + result (gld/calc-layout-data frame (bounds-for frame) [] {} {})] + (t/is (= 1 (count (:row-tracks result)))))) + (t/deftest grid-column-gap-space-between (t/testing "justify-content :space-between increases column-gap correctly" ;; free = 100; num-cols = 2; formula: 100 / (2-1) = 100