Repository navigation
fix(flexpanel): size an inner panel to its content when it is a flex item - #1676
Conversation
…item - a FlexPanel measured by a parent FlexPanel for content (AtMost/Undefined width) no longer fills the offered width; it was taking the whole line and leaving its Grow siblings with nothing - mirrors the existing height-axis handling (_parentFlexHeightMode) for the width axis; HorizontalAlignment != Stretch still opts into fit-content - tests: inner row item sized to content, growing inner item fills its share, inner panel in a centered column hugs its content
|
Azure Static Web Apps: Your stage site is ready! Visit it here: https://polite-field-01aa64f0f-1676.eastus2.azurestaticapps.net |
- outerFlexWantsContent becomes outerFlexWantsContentHeight beside the width one - the measure-function comment now says both modes are handed to the child
- inner row item is content-sized with and without Shrink=0 - inner panel in a default stretch column still fills it - centered inner panel's actual width hugs its content - nested Grow rows keep each level at two measures or fewer
|
Azure Static Web Apps: Your stage site is ready! Visit it here: https://polite-field-01aa64f0f-1676.eastus2.azurestaticapps.net |
Xiaoy312
left a comment
There was a problem hiding this comment.
LGTM. Verified locally on Desktop: the three new tests fail on main and pass here, and the rest of FlexPanelTests still passes.
One note on When_NestedRowsWithGrowSiblings_ThenMeasureCountDoesNotCompound: it also passes on main, so it doesn't really guard the new width-mode invalidation. The inner panels don't grow, so their final Exactly width equals the size already measured for the basis. Yoga reuses that cached measurement and never calls the measure function a second time, so the width mode never actually flips. (Height = 100 makes no difference here either: the counts are 1 per level with or without it.)
A variant where each inner panel has Grow="1" (next to a fixed-width sibling, with the root at VerticalAlignment="Top" so the height isn't definite) does exercise the AtMost → Exactly re-measure. Locally that gives counts of 1,2,3,4,5 by depth on both main and this PR, so it's linear rather than compounding. Note that the <= 2 per-level bound wouldn't hold there; the assertion would need to be something like <= depth + 1.
|
This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again. |
|
@Mergifyio backport servicing/10.0 |
✅ Backports have been createdDetails
|
…item (backport #1676) (#1677) * fix(flexpanel): size an inner panel to its content when it is a flex item - a FlexPanel measured by a parent FlexPanel for content (AtMost/Undefined width) no longer fills the offered width; it was taking the whole line and leaving its Grow siblings with nothing - mirrors the existing height-axis handling (_parentFlexHeightMode) for the width axis; HorizontalAlignment != Stretch still opts into fit-content - tests: inner row item sized to content, growing inner item fills its share, inner panel in a centered column hugs its content * refactor(flexpanel): name the height content flag after its axis - outerFlexWantsContent becomes outerFlexWantsContentHeight beside the width one - the measure-function comment now says both modes are handed to the child * test(flexpanel): guard nested-panel sizing on both paths - inner row item is content-sized with and without Shrink=0 - inner panel in a default stretch column still fills it - centered inner panel's actual width hugs its content - nested Grow rows keep each level at two measures or fewer * docs(flexpanel): explain how nested panels size (cherry picked from commit 73f4621) Co-authored-by: Kunal Shah <[email protected]>
GitHub Issue (If applicable): closes #1675
PR Type
What is the current behavior?
A
FlexPanelplaced directly inside anotherFlexPanelfills the width it is offered, even when the parent only measures it for its content (flex-basis resolution, or a non-stretch cross axis). In a row it takes the whole line, so itsGrowsiblings get no width; in a centered column it is full width instead of hugging its content. Details and repro in #1675.Out of scope: an inner panel behind another panel (
StackPanel,Border,Grid) still fills what that panel hands it — the parent-mode signal deliberately does not cross a non-FlexPanel, asWhen_InnerFlexPanelUnderGridRow_ThenFillsDefiniteSlotalready asserts.HorizontalAlignment="Left"on the inner panel remains the opt-out there.What is the new behavior?
As a flex item, an inner panel's base size is its content, as in CSS.
MeasureCorenow treats the width axis like the height axis already is: when the parentFlexPanelmeasures a direct child withAtMost/Undefinedwidth, the child reports its content width instead of the cap.Exactly(stretch, or a resolved grow share) still fills, andHorizontalAlignment != Stretchis still thefit-contentopt-in.The change is the width twin of
_parentFlexHeightMode: one more field, set by the parent's measure function on directFlexPanelchildren only, with the same invalidation when the mode changes.New runtime tests:
When_InnerFlexPanelIsRowItem_ThenSizedToContentAndGrowSiblingGetsRemainder(with and withoutShrink=0) — 80/520 instead of 600/0When_InnerFlexPanelIsGrowingRowItem_ThenFillsItsShare— 500 instead of 515When_InnerFlexPanelInCenteredColumn_ThenSizedToContent— 80 instead of 600When_InnerFlexPanelInStretchColumn_ThenFillsCrossAxis— guard: the default stretch column still fills (600)When_NestedRowsWithGrowSiblings_ThenMeasureCountDoesNotCompound— guard: five nested Grow rows stay at two measures or fewer per levelThe first three fail without the fix.
doc/controls/FlexPanel.mdgains a "Nesting FlexPanels" section: content-sized in a row unless grown, filled in a stretch column, andHorizontalAlignment="Left"when another panel sits in between.Behaviour change to note in the release: an inner
FlexPanelthat is not grown, or sits in a column withAlignItems/AlignSelfother thanStretch, now hugs its content instead of spanning the line. Restore the old fill withGrow="1"orAlignSelf="Stretch".PR Checklist
FlexPanelTestspass in the Material sample appservicing/10.0(FlexPanel shipped there via feat: FlexPanel (backport #1639) #1658) once this is reviewed