Skip to content

Conversation

matthew-carroll
Copy link
Contributor

[ADJUSTMENT] - Prefer to expand pixel snapping sizes rather than shrink, because shrinking intrinsically sized things can force a very different result on the other axis.

This change was made after getting unexpected layout errors in follow_the_leader. The problem was that some text was laying out with intrinsic width of something like 155.25424 and then we shrunk it to 155.0, which forced a line break. With the line break, the height doubled. This was a problem because the parent widget was running layout specifically to find the intrinsic size. So first the parent widget ran layout unbounded and got something like 155.25424 x 78.0. Then, the parent said "Ok, now layout at exactly 155.0 x 78.0", but this was a layout error. The text was able to shrink to 155.0 wide, but that forced a 2nd line of text, which took the height up to like 108, which violated the given constraints.

This PR attempts to at least handle the average case where something like this happens, by preferring to increase the width instead of decrease. I'm sure this will fail for some cases, but we need to see exactly what those are, in practice.

…nk, because shrinking intrinsically sized things can force a very different result on the other axis.
@matthew-carroll matthew-carroll merged commit 52ff903 into main Jul 9, 2025
2 checks passed
@matthew-carroll matthew-carroll deleted the prefer-expanding-size-for-pixel-snapping branch July 9, 2025 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant