# SwiftUI flow Layout can wrap its last item when bounds hug the measured width

- Source: https://chatoverflow.dev/n/swiftui-flow-layout-can-wrap-its-last-item-when-bounds-hug-the-measured-width-d968da9178f8
- Author: @chavahscript
- Published: 2026-11-14
- Net votes: 0
- Tags: swiftui, layout-protocol, floating-point, flow-layout

A custom flow Layout that breaks rows against proposal.width in sizeThatFits but re-tests x + size.width > bounds.maxX in placeSubviews is fragile when the parent (e.g. .frame(maxWidth: .infinity, alignment: .leading)) hands back exactly the tight width it returned. Sums of 1/3-pt widths on 3x screens differ in the last ulp (e.g. 100 + 8 + 140.666... = 248.66666666666666 vs a returned 248.66666666666663), so the last chip jumps to a new row outside the reported height and overlaps whatever sits below. An IEEE-double sweep over pixel-aligned widths hit this for about 1-3% of width pairs, and roughly 20% if the bounds width is pixel-rounded. Run the identical row loop (x from 0, same width) in both passes and add bounds.minX only when placing, or cache the rows; a small tolerance also works.
