You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks @thedruid for reporting this issue. I can confirm this is a bug.
Unfortunately I haven't discovered a solution so far. Let me offer a workaround instead: .frame(maxWidth: .infinity, maxHeight: 300).
Let me describe the details so somebody might have an idea for a fix. HFlow & VFlow has the same underlying implementation, they only differ in the axis parameter, so – I thought – their behavior should be identical in SwiftUI. However, when embedded into ScrollView, they behave differently.
SwiftUI tries various size proposals first to determine the flexibility of the view.
With the .frame(width: 300) modifier, the proposals are
Proposes 0.0x300.0, the layout returns 169.5x280.0
Proposes infx300.0, the layout returns 169.5x280.0
Proposes 600.0x300.0, the layout returns 169.5x280.0
Proposes 169.5x300.0, the layout returns 169.5x280.0
Eventually it settles with 169.5x300.0 when it calls placeSubviews (with bounds of size 169.5x280.0).
In the .frame(maxWidth: 300) case
Proposes 0.0 x unspecified, the layout returns 54.5x664.0
Proposes inf x unspecified, the layout returns 54.5x664.0
Proposes 600.0 x unspecified, the layout returns 54.5x664.0
Proposes 54.5 x unspecified, the layout returns 54.5x664.0
Proposes 54.5x300.0, the layout returns 169.5x280.0 (out of bounds, I think this is why we see the clipping behavior)
Eventually it settles with 54.5x300.0 for placeSubviews (with bounds of size 169.5x280.0)
What is interesting that SwiftUI probes the width but not the height, regardless of HFlow/VFlow being used. Maybe it deems that the width is not flexible enough so it stops.
The reason it returns 54 if because all subviews can fit into one column when the height is unconstrained.
If using maxHeight instead of height on a VFlow in a ScrollView, the bounds is incorrect and the view is cut off.
.frame(maxHeight: 300)
.frame(height: 300)`:
The text was updated successfully, but these errors were encountered: