Skip to content

fix(pivot): Measure PivotItem content with the Pivot's width (port PivotPanel) - #25143

Merged
MartinZikmund merged 2 commits into
masterfrom
dev/mazi/pivot-panel-measure
Oct 9, 2026
Merged

MartinZikmund merged 2 commits into
masterfrom
dev/mazi/pivot-panel-measure

Conversation

@MartinZikmund

@MartinZikmund MartinZikmund commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

GitHub Issue: closes #21729

Related: #3596

PR Type:

🐞 Bugfix

What changed? 🚀

Before: Content inside a PivotItem was measured with infinite width, so TextBlock/RichTextBlock/TextBox with TextWrapping="Wrap" never wrapped and got clipped. Uno's Pivot template had a plain <Grid x:Name="Panel"> inside the template's ScrollViewer (horizontal scrolling allowed, so infinite width). WinUI uses <PivotPanel x:Name="Panel"> there. PivotPanel::MeasureOverrideImpl measures PivotLayoutElement with the Pivot's section width, "to lay out the PivotItems with a fixed size, even though we're in a ScrollViewer that will measure with infinite extents".

After:

  • PivotPanel: ported measure/arrange from dxaml/phone/lib/PivotPanel_Partial.cpp / .h (commit 4a1c6184c) into PivotPanel.partial.mux.cs / PivotPanel.partial.h.mux.cs. This replaces Uno's old PivotPanel, which was never used by any template and read the viewport size from the parent ScrollViewer.
  • Pivot:
    • MeasureOverride/ArrangeOverride now replace an infinite width with the XamlRoot width (Pivot::GetScreenWidth) and pass the measure width to the panel through SetSectionWidth. This stands in for PivotStateMachine::MeasureEvent and uses the same 0.1 AreClose threshold.
    • OnApplyTemplate wires SetParentPivot.
    • Adds the c_*Name template part constants and GetPivotPanelMultiplier.
  • Templates: Generic.xaml and Fluent Pivot_themeresources.xaml now use <PivotPanel x:Name="Panel">, matching WinUI. This also removes the Fluent UNO TODO about PivotPanel in Pivot only shows one header #3596. That header bug does not reproduce with the ported panel (see tests and the manual check below).

Deliberate deviations (marked TODO Uno):

  • Pivot.GetPivotPanelMultiplierImpl() returns 1 instead of WinUI's 1000 (carousel) or item count. Uno's Pivot switches items by toggling Visibility and never pans the ScrollViewer between sections. A 1000x-wide extent would only let users scroll into empty space, so the panel spans exactly one section.
  • IScrollSnapPointsInfo (snap points) and InvalidateHeaderSecondaryContentRelationships are kept as #if !HAS_UNO for the same reason. The generated NotImplemented snap-point stubs are unchanged.

I chose the faithful port over a smaller Uno-specific clamp so the template and Panel contract match WinUI. That gives a base for porting the panning state machine later.

Validation

Runtime (Skia desktop, Given_Pivot, net10.0-desktop Release):

  • Before the fix: When_PivotItem_Has_Wrapping_Text_Then_Measured_With_Pivot_Width failed for both inScrollViewer variants.
    Assert.IsLessThanOrEqualTo failed. Actual value <3642.39990234375> is not less than or equal to expected value <300>.
    'value' expression: 'textBlock.DesiredSize.Width'. Wrapping text should be measured with the Pivot's width
    
  • After the fix: all 9 Given_Pivot tests pass. I also ran KeyboardAcceleratorTests, which includes ValidateKeyboardAcceleratorToolTipsOnPivot: 54 total, 54 passed, 0 failed (9 skipped by existing attributes).
  • When_Multiple_Items_Then_Headers_Not_Stretched is a regression guard for PivotPanel in Pivot only shows one header #3596 and passes with the PivotPanel template.

Manual: in SamplesApp, Pivot/Basics Pivot Test renders all four headers (First/Second/Third/Fourth) side by side with no stretched header.

PR Checklist ✅

🤖 Generated with Claude Code

https://claude.ai/code/session_01E8bkzyS24p8CYDWLUPsaPC

MartinZikmund and others added 2 commits October 9, 2026 12:33
Port WinUI's PivotPanel measure/arrange (PivotPanel_Partial.cpp) and use it
as the Pivot template's "Panel", as WinUI does. Pivot hands its available
width to the panel as the section width, so items are no longer measured
with the infinite width of the template's ScrollViewer and wrapping text
wraps instead of being clipped.

Fixes #21729

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01E8bkzyS24p8CYDWLUPsaPC
Copilot AI balanced review requested due to automatic review settings October 9, 2026 10:34
@MartinZikmund MartinZikmund self-assigned this Oct 9, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 27s —— View job


PR review: Pivot / PivotPanel port

Verdict: ship, with one low-severity item.

Severity Count
High / Medium 0
Low 1

I read the diff by inspection only. I did not build or run tests, so the runtime results in the PR description are the author's, not mine.

What looks good

  • The PivotPanel port follows PivotPanel_Partial.cpp, with MUX headers and reference commit.
  • The deviations are marked TODO Uno and explained: multiplier of 1, and the snap-point and header-relationship code under #if !HAS_UNO.
  • Pivot.OnApplyTemplate clears the old panel's parent reference before wiring the new one. The panel holds the Pivot only through a WeakReference.
  • Tests cover the red case, with a before-fix failure, and the PivotPanel in Pivot only shows one header #3596 header regression guard. No skipped or ignored tests were added.
  • Style matches the repo's rules: braces, tabs, no event Action.

Cross-cutting notes

  • Only the in-repo templates (Generic.xaml and Fluent) switch to PivotPanel. Templates that live elsewhere, such as external Material or Cupertino theme repos or user-defined templates, that still use <Grid x:Name="Panel"> keep the infinite-width wrapping bug. Their Panel part is not a PivotPanel, so _panel stays null and nothing breaks. It may be worth a follow-up or a note in the docs or release notes.
  • The Pivot MeasureOverride and ArrangeOverride now replace an infinite width with the XamlRoot width. This changes sizing for any Pivot placed in a horizontally unbounded container, which is the intended WinUI behavior. I covered one edge case inline.
  • The PR checklist items for docs and the screenshot-compare run are still unchecked.

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 238482 found UI Test snapshots differences: skia-linux-screenshots: 118, skia-windows-screenshots: 1146

Details
  • skia-linux-screenshots: 118 changed over 2458

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ClipboardTests.png-dark
    • ButtonClippingTestsControl.png-dark
    • Buttons.png-dark
    • ButtonClippingTestsControl.png
    • Buttons.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • CompositionEffectBrush.png-dark
    • CompositionEffectBrush.png
    • CompositionNineGridBrush_Source_Changes.png-dark
    • CompositionNineGridBrush_Source_Changes.png
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
    • DisplayInformation.png-dark
    • DoubleImageBrushInList.png-dark
    • DoubleImageBrushInList.png
    • Examples.png
    • ImageIconPage.png-dark
    • ImageIconPage.png
    • DynamicFont.png-dark
  • skia-windows-screenshots: 1146 changed over 2474

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AnimatedIconPage.png
    • AppWindowFeatures.png
    • AutoBorderStretchwithrightmargin.png-dark
    • AutoBorderStretchwithrightmargin.png
    • BackGesture.png-dark
    • BackGesture.png
    • Basics.png-dark
    • Basics.png
    • BorderLeftwithmargins.png-dark
    • BorderLeftwithmargins.png
    • Border_Simple.png-dark
    • Border_Simple.png
    • CalendarDatePicker_Description.png-dark
    • CalendarDatePicker_Description.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • ColorPickerSample.png-dark
    • ColorPickerSample.png
    • ComboBox_DropDownPlacement.png-dark
    • ComboBox_DropDownPlacement.png

@MartinZikmund

Copy link
Copy Markdown
Member Author

Follow-up on the review summary and the screenshot report:

  • Low-severity XamlRoot fallback — answered inline; 0.0 matches WinUI's Pivot::GetScreenWidth exactly.
  • Out-of-repo templates still using <Grid x:Name="Panel"> — correct, those keep the old behavior (_panel stays null, nothing breaks). Matching WinUI means the template part should be a PivotPanel; worth a release-notes line rather than a code fallback.
  • Screenshot diffs (118 linux / 1146 windows) — same baseline noise as other current PRs (perf(listview): Drop dead recycle visibility pass #24529: 118 / 1190, fix(wasm): Size strided WebGL uploads to their row length #25147: 118 / 1164), not specific to this change.

@MartinZikmund
MartinZikmund merged commit 2798fff into master Oct 9, 2026
50 checks passed
@MartinZikmund
MartinZikmund deleted the dev/mazi/pivot-panel-measure branch October 9, 2026 20:04
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.

Pivot control text wrapping fails with TextBox/RichEditBox/TextBlock on Desktop/Skia

3 participants