diff --git a/common/src/app/common/geom/shapes/flex_layout/layout_data.cljc b/common/src/app/common/geom/shapes/flex_layout/layout_data.cljc index da81f5b876..c960d4414d 100644 --- a/common/src/app/common/geom/shapes/flex_layout/layout_data.cljc +++ b/common/src/app/common/geom/shapes/flex_layout/layout_data.cljc @@ -224,12 +224,12 @@ ;; When align-items is stretch we need to adjust the main axis size to grow for the full content stretch-width-fix - (if (and col? (ctl/content-stretch? parent) (not auto-width?)) + (if (and (pos? num-lines) col? (ctl/content-stretch? parent) (not auto-width?)) (/ (- layout-width (* layout-gap-col (dec num-lines)) total-max-width) num-lines) 0) stretch-height-fix - (if (and row? (ctl/content-stretch? parent) (not auto-height?)) + (if (and (pos? num-lines) row? (ctl/content-stretch? parent) (not auto-height?)) (/ (- layout-height (* layout-gap-row (dec num-lines)) total-max-height) num-lines) 0) @@ -300,7 +300,8 @@ [total-width total-height] (->> layout-lines (reduce add-lines [0 0])) - base-p (flp/get-base-line parent layout-bounds total-width total-height num-lines)] + base-p (when (pos? num-lines) + (flp/get-base-line parent layout-bounds total-width total-height num-lines))] (->> layout-lines (reduce (partial add-starts total-width total-height num-lines) [(transient []) base-p]) diff --git a/common/test/common_tests/geom_flex_layout_test.cljc b/common/test/common_tests/geom_flex_layout_test.cljc index 746b2cbef1..2746ead5ed 100644 --- a/common/test/common_tests/geom_flex_layout_test.cljc +++ b/common/test/common_tests/geom_flex_layout_test.cljc @@ -34,6 +34,16 @@ [rect] (grc/rect->points rect)) +(t/deftest empty-wrapped-layout-has-no-lines + (doseq [direction [:row :column] + alignment [:stretch :space-around :space-evenly :space-between :center :end]] + (let [frame (make-col-frame :layout-flex-dir direction + :layout-align-content alignment + :layout-padding {:p1 0 :p2 0 :p3 0 :p4 0} + :layout-padding-type :simple) + bounds (rect->bounds (grc/make-rect 0 0 200 200))] + (t/is (= [] (:layout-lines (fld/calc-layout-data frame bounds [] {} {}))))))) + ;; ---- get-base-line (around? branch) ---- ;; ;; Bug: in positions.cljc the col? + around? branch had a mis-parenthesised