Repository navigation
Measure a container with no room past its padding as the padding alone [patch] - #254
Open
matt-edmondson wants to merge 1 commit into
Open
matt-edmondson wants to merge 1 commit into
matt-edmondson wants to merge 1 commit into
Conversation
…ing alone UIContainerBase measured its children at width 0 when the container got no more width than its padding, and TextElement reads 0 as "no constraint". A BorderElement squeezed to 2 columns then reported its child's full unwrapped height, drew a hollow box that tall and pushed the siblings below it down. The container now returns the padding alone in that case, as TextElement does since #198. Fixes #249 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW4towbdqS7BHdCDNqm
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Fixes #249
What changed
When a container got no more width than its padding (2 columns or fewer for a
BorderElement),UIContainerBase.OnCalculateRequiredDimensions(int)measured its children atMath.Max(0, availableWidth - Padding.Horizontal), which is 0.TextElementreads 0 as "no constraint", so a word-wrapped child reported its full unwrapped height. In the issue's layout, the squeezed border drew a hollow 2×7 box, and"below"landed at y=7 instead of y=2. This is #198's symptom again, reached through a container rather than throughTextElementitself.For
0 < availableWidth <= Padding.Horizontal, the container now returnsDimensions.Empty.WithPadding(Padding)without measuring its children. This is the same branchTextElementgot for #198. The unconstrained (0) and roomier cases measure exactly as before. The longer-term change the issue mentions, a nullable width instead of 0 meaning "unconstrained", is left out of this PR.Tests
The tests are in a new file,
ContainerNoRoomMeasureTests:BorderWithNoRoomForItsChildMeasuresAsTheBareBorder(1|2): a bordered wrapped child measures 2×2BorderWithOneColumnOfRoomStillMeasuresItsChild: width 3 still measures the child (3×4)SqueezedBorderDoesNotPushTheNextRowDown: the issue's 19×20 layout puts"below"at y=2With the
UIContainerBasechange reverted, the two no-room cases and the layout test fail. The full suite passes (331/331). The branch also merges cleanly with open PR #252, which edits nearby measurement code for #190.Generated by Claude Code