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 756eb2924e..1dd7524f40 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 @@ -513,7 +513,7 @@ (max column-gap (/ (- bound-width column-total-size) (inc num-columns))) (= :space-around (:layout-justify-content parent)) - (max column-gap (/ (- bound-width column-total-size) num-columns)) + (max column-gap (if (zero? num-columns) column-gap (/ (- bound-width column-total-size) num-columns))) (= :space-between (:layout-justify-content parent)) (max column-gap (if (= num-columns 1) column-gap (/ (- bound-width column-total-size) (dec num-columns)))) @@ -531,7 +531,7 @@ (max row-gap (/ (- bound-height row-total-size) (inc num-rows))) (= :space-around (:layout-align-content parent)) - (max row-gap (/ (- bound-height row-total-size) num-rows)) + (max row-gap (if (zero? num-rows) row-gap (/ (- bound-height row-total-size) num-rows))) (= :space-between (:layout-align-content parent)) (max row-gap (if (= num-rows 1) row-gap (/ (- bound-height row-total-size) (dec num-rows)))) diff --git a/common/test/common_tests/geom_grid_layout_test.cljc b/common/test/common_tests/geom_grid_layout_test.cljc index ac642b2d43..68a9ffaa5b 100644 --- a/common/test/common_tests/geom_grid_layout_test.cljc +++ b/common/test/common_tests/geom_grid_layout_test.cljc @@ -156,6 +156,16 @@ col-gap (:column-gap result)] (t/is (mth/close? 50.0 col-gap 0.01))))) +(t/deftest grid-gap-space-around-without-tracks-keeps-the-gap + (let [frame (make-grid-frame :layout-justify-content :space-around + :layout-align-content :space-around + :layout-grid-columns [] + :layout-grid-rows [] + :layout-gap {:column-gap 5 :row-gap 7}) + result (gld/calc-layout-data frame (bounds-for frame) [] {} {})] + (t/is (mth/close? 5 (:column-gap result))) + (t/is (mth/close? 7 (:row-gap 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