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