Skip to content

fix(flexpanel): size an inner panel to its content when it is a flex item (backport #1676) - #1677

Merged
Kunal22shah merged 1 commit into
servicing/10.0from
mergify/bp/servicing/10.0/pr-1676
Oct 14, 2026
Merged

Kunal22shah merged 1 commit into
servicing/10.0from
mergify/bp/servicing/10.0/pr-1676

Conversation

@mergify

@mergify mergify Bot commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

GitHub Issue (If applicable): closes #1675

PR Type

  • Bugfix

What is the current behavior?

A FlexPanel placed directly inside another FlexPanel fills 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 its Grow siblings 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, as When_InnerFlexPanelUnderGridRow_ThenFillsDefiniteSlot already 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. MeasureCore now treats the width axis like the height axis already is: when the parent FlexPanel measures a direct child with AtMost / Undefined width, the child reports its content width instead of the cap. Exactly (stretch, or a resolved grow share) still fills, and HorizontalAlignment != Stretch is still the fit-content opt-in.

The change is the width twin of _parentFlexHeightMode: one more field, set by the parent's measure function on direct FlexPanel children only, with the same invalidation when the mode changes.

New runtime tests:

  • When_InnerFlexPanelIsRowItem_ThenSizedToContentAndGrowSiblingGetsRemainder (with and without Shrink=0) — 80/520 instead of 600/0
  • When_InnerFlexPanelIsGrowingRowItem_ThenFillsItsShare — 500 instead of 515
  • When_InnerFlexPanelInCenteredColumn_ThenSizedToContent — 80 instead of 600
  • When_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 level

The first three fail without the fix. doc/controls/FlexPanel.md gains a "Nesting FlexPanels" section: content-sized in a row unless grown, filled in a stretch column, and HorizontalAlignment="Left" when another panel sits in between.

Behaviour change to note in the release: an inner FlexPanel that is not grown, or sits in a column with AlignItems/AlignSelf other than Stretch, now hugs its content instead of spanning the line. Restore the old fill with Grow="1" or AlignSelf="Stretch".

PR Checklist

  • Tested the changes where applicable:
    • Desktop (Windows) — all 37 FlexPanelTests pass in the Material sample app
  • Runtime tests added
  • Backport to servicing/10.0 (FlexPanel shipped there via feat: FlexPanel (backport #1639) #1658) once this is reviewed

This is an automatic backport of pull request #1676 done by [Mergify](https://mergify.com).

…item (#1676)

* 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)
@mergify

mergify Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor Author

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.

@Kunal22shah
Kunal22shah merged commit 829a413 into servicing/10.0 Oct 14, 2026
20 checks passed
@Kunal22shah
Kunal22shah deleted the mergify/bp/servicing/10.0/pr-1676 branch October 14, 2026 20:42
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.

2 participants