diff --git a/common/src/app/common/geom/shapes/flex_layout/positions.cljc b/common/src/app/common/geom/shapes/flex_layout/positions.cljc index 2dcb28d42d..ad32a4c24f 100644 --- a/common/src/app/common/geom/shapes/flex_layout/positions.cljc +++ b/common/src/app/common/geom/shapes/flex_layout/positions.cljc @@ -98,7 +98,8 @@ stretch? (/ free-width num-lines) - between? + ;; a single line has no gap to share + (and between? (> num-lines 1)) (/ free-width (dec num-lines)) around? @@ -118,7 +119,7 @@ stretch? (/ free-height num-lines) - between? + (and between? (> num-lines 1)) (/ free-height (dec num-lines)) around? diff --git a/common/test/common_tests/geom_flex_layout_test.cljc b/common/test/common_tests/geom_flex_layout_test.cljc index e727c2abc3..160b4abd02 100644 --- a/common/test/common_tests/geom_flex_layout_test.cljc +++ b/common/test/common_tests/geom_flex_layout_test.cljc @@ -60,6 +60,15 @@ (t/is (== (if (= children 1) (if row? 7 11) (if row? 100 140)) gap)) (t/is (every? mth/finite? (map line [:layout-gap-col :layout-gap-row :margin-x :margin-y])))))) +(t/deftest next-line-after-a-single-space-between-line-is-finite + (doseq [direction [:row :column]] + (let [frame (make-col-frame :layout-flex-dir direction + :layout-align-content :space-between) + bounds (rect->bounds (grc/make-rect 0 0 200 200)) + base-p (flp/get-base-line frame bounds 50 30 1) + next-p (flp/get-next-line frame bounds {:line-width 50 :line-height 30} base-p 50 30 1)] + (t/is (every? mth/finite? [(:x next-p) (:y next-p)]))))) + ;; ---- get-base-line (around? branch) ---- ;; ;; Bug: in positions.cljc the col? + around? branch had a mis-parenthesised diff --git a/common/test/common_tests/logic/composable_gen_test.cljc b/common/test/common_tests/logic/composable_gen_test.cljc index b2e91c8c5c..337dfd572c 100644 --- a/common/test/common_tests/logic/composable_gen_test.cljc +++ b/common/test/common_tests/logic/composable_gen_test.cljc @@ -1019,3 +1019,10 @@ :library-depth 1 :library true :rich-variants true :library-text true :layout-copies true :text true}] :ops [[:transform 0 4 0 2] [:switch 0 0 0 0]]})))) + +(t/deftest generated-single-line-flex-set-to-space-between-lays-out + ;; aligning the content of a one-line wrapped flex main by space-between + ;; leaves no gap to share between its lines + (t/is (map? (cg/run {:world [2 0 {:variants true :text-styles true :layout :flex :library true + :rich-variants true :layout-copies true :text true}] + :ops [[:style 0 23 18 0]]}))))