Skip to content

fix(menubar): Sync MenuBar with WinUI 2.7.0 and track it - #26612

Merged
MartinZikmund merged 7 commits into
masterfrom
dev/mazi/winui-sync-menubar
Nov 23, 2026
Merged

MartinZikmund merged 7 commits into
masterfrom
dev/mazi/winui-sync-menubar

Conversation

@MartinZikmund

@MartinZikmund MartinZikmund commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

GitHub Issue: closes unoplatform/uno-private#2622

PR Type:

🐞 Bugfix

What changed? 🚀

This onboards MenuBar to the WinUI port sync (build/winui-sync/areas/menubar.json) at winui3/release/2.7.0, after bringing the port up to that release.

Starting point

  • The two automation peers name winui3/release/1.8.4 in their headers. The other five files had no header.
  • Upstream MenuBar C++ code hasn't changed since the 1.5.5 import into src/. Between 1.8.4 and 2.7.0, only MenuBar.vcxitems changed (not applicable).
  • The only content commit in that range (67723ef2d, the MenuBarItemForeground theme resource) predates 1.8.4, and Uno's theme XAML already has it.
  • Catch-up diff: none to port.

The headerless files turned out to be an older WinUI 2 era port, so the line-by-line review found real gaps (below).

Upstream changes

Change Verdict
MenuBar.vcxitems (+9) Not applicable (C++ build file)
MenuBar_InteractionTests/* (inside the mapped source folder) Not applicable: interaction tests are out of scope for onboarding

Nothing was skipped, so there is no skipped-items issue.

Review (2.7.0 vs Uno)

Upstream Uno Gaps fixed Still differs (marked)
MenuBar.cpp/.h MenuBar.cs Items is an ObservableVector whose VectorChanged updates PositionInSet/SizeOfSet (UpdateAutomationSizeAndPosition was missing); RequestPassThroughElement was missing; SetUpTemplateParts split none
MenuBarItem.cpp/.h MenuBarItem.cs OnApplyTemplate asks the MenuBar for its pass-through element (was #if false, so the flyout never had one) and detaches handlers before attaching. OnMenuBarItemKeyDown ignores keys while Alt is down; Left/Right now move focus (MoveFocusTo) and mark the event handled. OnPresenterKeyDown leaves Left/Right to a MenuFlyoutSubItem with items. ShowMenuFlyout opens nothing when Items is empty (it used to show an empty popup) and replaces the presenter KeyDown handler instead of adding one on every open. OpenFlyoutFrom uses FocusAndReturnNextFocusableItem, which was missing, so disabled items are skipped. OnFlyoutOpening focuses Programmatic (was Pointer). UpdateVisualStates checks Pressed > PointerOver > Selected/Normal (Selected came first). The dead IsFlyoutShowOptionsAvailable branch is gone. EnterImpl/LeaveImpl (Uno specific: Items is not a DependencyObject, so its keyboard accelerators are entered explicitly); IsFlyoutOpen() and Invoke() are public in Uno, implementation-only in WinUI (marked, kept to avoid an API break); OnPresenterKeyDown checks Count > 0 before [0] (marked)
MenuBarItemFlyout.cpp/.h MenuBarItemFlyout.cs header none
MenuBarAutomationPeer.cpp/.h MenuBarAutomationPeer.cs none none
MenuBarItemAutomationPeer.cpp/.h MenuBarItemAutomationPeer.cs null-tolerant as casts are direct casts, like upstream none
MenuBar.idl MenuBarItem.Properties.cs, MenuBar.cs header; MenuBar.Items is get-only like the IDL (its setter was private) none
MenuBarItem.h (FlyoutLocation) FlyoutLocation.cs header none
MenuBar.xaml, MenuBarItem.xaml, MenuBar_themeresources.xaml FluentTheme PriorityDefault none: byte-identical to 2.7.0 mapped as mirrors
MenuBar_TestUI/MenuBarPage.xaml(.cs) SamplesApp MenuBarTests/MenuBarPage ported as a sample the test-frame checkbox handlers are empty (TODO Uno: no TestPage frame in SamplesApp)

Workarounds

Location What it did Verdict Evidence
MenuBarItem Loaded handler Re-resolved the parent MenuBar after load Removed The pass-through and keyboard tests pass without it: OnApplyTemplate finds the MenuBar, as in WinUI
MenuBarItem #if false AddPassThroughElement Disabled the pass-through element Removed (ported) When_Flyout_Open_Then_MenuBar_Root_Is_Pass_Through_Element
MenuBarItem.EnterImpl/LeaveImpl Enter/leave the items' keyboard accelerators Kept Items isn't a DO, so EnterSparseProperties doesn't reach it; the KeyboardAcceleratorTests MenuBar tests cover it
ShowMenuFlyout IsFlyoutShowOptionsAvailable branch Fallback for platforms without FlyoutShowOptions Removed Always true

Not fixed here (pre-existing)

With a MenuBarItem flyout open, Right/Left moves focus to the next enabled item and opens its flyout, which then closes immediately.

Tests (Skia desktop)

  • New: Given_MenuBar, 6 tests. 4 fail on the old port and pass on the new one; the 6th is the ignored next-flyout test above.
  • Full related run: 136 passed, 0 failed. This covers Given_MenuBar, Given_MenuFlyout, Given_Flyout.Test_Flyout_Binding_In_MenuFlyoutItem, the 3 MenuBar KeyboardAcceleratorTests, the whole Given_FrameworkElement_And_Leak suite (including MenuBar) and Given_ControlsLibraryAutomationPeerClassName.
  • Strict build (analyzers on): Uno.UI.RuntimeTests.Generic and the SamplesApp desktop head are clean.
  • Sync tooling: detect.ps1 reports menubar up to date, and build/winui-sync/tests/run.ps1 passes 134/134.

PR Checklist ✅

🤖 Generated with Claude Code

https://claude.ai/code/session_01TXMNu2vyo2nCA7nYdY9GPd

@github-actions github-actions Bot added area/build Categorizes an issue or PR as relevant to build infrastructure area/automation Categorizes an issue or PR as relevant to project automation labels Nov 20, 2026
@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

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


Review summary: PR #26612

Verdict: ship after considering the two comments. There are no blockers.

Findings: 0 high, 0 medium, 2 low (both inline).

Overall

  • The port is faithful to WinUI 2.7.0, and the deviations are marked Uno specific.
  • The Loaded handler and the #if false workaround are removed with test evidence.
  • The tests are new and no tests are ignored.
  • Style is fine: braces, tabs, EventHandler, and no native-platform paths.
  • The known open-next-flyout bug is disclosed as pre-existing. Its coverage gap and the possible double key handling are noted inline.

Not verified: I reviewed the diff by inspection only. I did not build or run tests.

@mergify

mergify Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

This pull request is merged.

@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 247861 found UI Test snapshots differences: skia-linux-screenshots: 236, skia-windows-screenshots: 278

Details
  • skia-linux-screenshots: 236 changed over 2502

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AnimatedBackVisualSourceSamplePage.png
    • AppWindowTitleBar Properties.png-dark
    • BreadcrumbBarPage.png-dark
    • BreadcrumbBarPage.png
    • Accessibility_Showcase.png-dark
    • AnimatedVisualsTestbedPage.png
    • AppWindowTitleBar Properties.png
    • AutomationProperties_StructureAndProps.png-dark
    • AutomationProperties_StructureAndProps.png
    • Basics.png-dark
    • Basics.png
    • Buttons.png-dark
    • Buttons.png
    • ClipboardTests.png-dark
    • ClipboardTests.png
    • CompositionNineGridBrush_Source_Changes.png-dark
    • CompositionNineGridBrush_Source_Changes.png
    • AutomationProperties_AutomationId.png-dark
    • BenchmarkDotNet.png-dark
    • BenchmarkDotNet.png
  • skia-windows-screenshots: 278 changed over 2502

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AppWindowTitleBar Properties.png-dark
    • BreadcrumbBarPage.png-dark
    • BreadcrumbBarPage.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • AnimatedBackVisualSourceSamplePage.png
    • AutomationProperties_StructureAndProps.png-dark
    • AutomationProperties_StructureAndProps.png
    • Buttons.png-dark
    • ClipboardTests.png-dark
    • ClipboardTests.png
    • AnimatedBackVisualSourceSamplePage.png-dark
    • AppWindowTitleBar Properties.png
    • AutomationProperties_AutomationId.png-dark
    • BenchmarkDotNet.png-dark
    • BenchmarkDotNet.png
    • Accessibility_Showcase.png-dark
    • AnimatedVisualsTestbedPage.png-dark
    • AnimatedVisualsTestbedPage.png
    • Basics.png-dark

@MartinZikmund
MartinZikmund force-pushed the dev/mazi/winui-sync-menubar branch 2 times, most recently from fdbb649 to 50e8981 Compare November 23, 2026 07:46
@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

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


Review summary: PR #26612 (updated after the [Ignore]d test commit)

Verdict: ship, with one tracked caveat. I found no blockers.

Findings: 0 high, 1 medium, 0 low.

  • Medium: an [Ignore]d test. Given_MenuBar.When_Flyout_Open_And_Right_Arrow_Then_Next_Flyout_Opens is [Ignore]d (Given_MenuBar.cs:61). Repo review rules flag deactivated tests.

Earlier review comments (resolved by the author's replies)

  • Null check on m_presenter: the author's explanation holds. ShowAt creates the presenter synchronously via EnsurePopupCreated, and WinUI dereferences it unguarded too, so no change is needed.
  • Double key handling: the author's probe shows the key never reaches the MenuBarItems while the flyout is open, so this is not a concern.
  • Nested ifs and LINQ in UpdateAutomationSizeAndPosition: keeping the upstream structure for sync diffability is reasonable.

Cross-cutting checks

  • Style, events (EventHandler) and the absence of native-platform paths all conform to AGENTS.md.
  • Workarounds were removed with test evidence, and deviations are marked Uno specific.
  • The MenuBar sample XAML was not re-checked for XamlStyler formatting. Run dotnet xstyler -d src/SamplesApp -r if CI complains.
  • Screenshot differences: the CI report lists 236 (Linux) and 278 (Windows) changed screenshots, including pages unrelated to MenuBar such as Buttons and BreadcrumbBarPage. That pattern looks like baseline or infrastructure noise rather than this PR. Please confirm against the base build before merging.

Not verified: I reviewed by inspection only. I did not build or run tests.

@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

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


Review summary: PR #26612

Verdict: ship, with one tracked caveat. No blockers.

Findings: 0 high, 1 medium, 0 low (inline).

Cross-cutting notes

  • The port follows WinUI 2.7.0, and deviations are marked Uno specific.
  • Earlier review threads (null check on m_presenter, double key handling, nested ifs in UpdateAutomationSizeAndPosition) are resolved by the author's replies.
  • The 236/278 screenshot differences include unrelated pages (Buttons, BreadcrumbBarPage), which looks like baseline noise. Please confirm against the base build before merging.
  • Not verified: I reviewed by inspection only and did not build or run tests.

MartinZikmund and others added 6 commits November 23, 2026 09:30
Brings the port in line with MenuBar.cpp and MenuBarItem.cpp: arrow keys move
focus between items and skip disabled ones, the MenuBar root is the flyout's
pass-through element, empty items open no flyout, visual states follow the
WinUI order and items get PositionInSet/SizeOfSet.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TXMNu2vyo2nCA7nYdY9GPd
MenuBarItem no longer re-resolves its MenuBar on Loaded: OnApplyTemplate
finds it, as in WinUI, and the pass-through and keyboard tests pass without
the handler.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TXMNu2vyo2nCA7nYdY9GPd
Ports MenuBar_TestUI/MenuBarPage as a sample and covers the synced behavior:
arrow-key focus skipping disabled items, empty items, the pass-through
element and PositionInSet/SizeOfSet.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TXMNu2vyo2nCA7nYdY9GPd
Recorded at winui3/release/2.7.0. The theme XAML is verbatim upstream, so
it is mirrored. Interaction tests stay unmapped.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TXMNu2vyo2nCA7nYdY9GPd
Ignored for now: the next flyout closes right after it opens, because the
deferred Closed callback in FlyoutBase.RemoveFromOpenFlyouts hides the
newly opened flyout (pre-existing, unrelated to the port).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TXMNtzaC5dx4oo2ZVG5BHB
VisualTreeHelper.CloseAllPopups and MenuBarItem.IsFlyoutOpen() are
public on Uno only. Close popups through UITestHelper.CloseAllPopups and
read the flyout's IsOpen on WinUI.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TXMNtzaC5dx4oo2ZVG5BHB
@MartinZikmund
MartinZikmund force-pushed the dev/mazi/winui-sync-menubar branch from a6840c1 to d8602a3 Compare November 23, 2026 08:34
@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

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


Review summary: PR #26612

Verdict: ship, with one tracked caveat. There are no blockers.

Findings: 0 high, 1 medium, 0 low. The medium is the existing inline comment on Given_MenuBar.cs:62.

Cross-cutting notes

  • The [Ignore] on When_Flyout_Open_And_Right_Arrow_Then_Next_Flyout_Opens (Given_MenuBar.cs:62) still has no issue reference. Adding one (e.g. #26399) would tie the skip to the fix.
  • The port follows WinUI 2.7.0, and deviations are marked Uno specific.
  • The earlier review threads are resolved by your replies: the null check on m_presenter, double key handling, and the nested ifs in UpdateAutomationSizeAndPosition.
  • The 236 and 278 screenshot differences include pages unrelated to MenuBar (Buttons, BreadcrumbBarPage). That looks like baseline noise. Please confirm against the base build before merging.
  • I did not re-run dotnet xstyler on the MenuBar sample XAML. If CI complains, run dotnet xstyler -d src/SamplesApp -r.

Not verified: I reviewed by inspection only. I did not build or run tests. I made no code changes.

@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 248335 found UI Test snapshots differences: skia-linux-screenshots: 259, skia-windows-screenshots: 252

Details
  • skia-linux-screenshots: 259 changed over 2504

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AnimatedVisualsTestbedPage.png-dark
    • AutomationProperties_AutomationId.png-dark
    • BenchmarkDotNet.png-dark
    • BenchmarkDotNet.png
    • Accessibility_Showcase.png-dark
    • AppWindowTitleBar Properties.png
    • AutomationProperties_AutomationId.png
    • Basics.png-dark
    • Basics.png
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • BreadcrumbBarPage.png-dark
    • BreadcrumbBarPage.png
    • AnimatedBackVisualSourceSamplePage.png-dark
    • AutomationProperties_StructureAndProps.png-dark
    • AutomationProperties_StructureAndProps.png
    • BasicAcrylicBrushTest2.png-dark
    • BasicAcrylicBrushTest2.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
  • skia-windows-screenshots: 252 changed over 2504

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Accessibility_Showcase.png-dark
    • AnimatedBackVisualSourceSamplePage.png
    • AppWindowTitleBar Properties.png-dark
    • AutomationProperties_StructureAndProps.png-dark
    • AutomationProperties_StructureAndProps.png
    • Buttons.png-dark
    • ClipboardTests.png-dark
    • AutomationProperties_AutomationId.png
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • AnimatedBackVisualSourceSamplePage.png-dark
    • Basics.png-dark
    • Basics.png
    • Border_CornerRadius_BorderThickness.png-dark
    • Border_CornerRadius_BorderThickness.png
    • BenchmarkDotNet.png-dark
    • BenchmarkDotNet.png
    • AppWindowTitleBar Properties.png

@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

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


Review summary: PR #26612 (after 4a6033f6)

Verdict: ship. No blockers, and no new inline findings.

Findings: 0 high, 0 medium, 0 low.

  • The earlier medium finding is resolved. The [Ignore] on Given_MenuBar.When_Flyout_Open_And_Right_Arrow_Then_Next_Flyout_Opens now links MenuBar: Left/Right with a flyout open opens the next item's flyout, which closes immediately #26654 and carries a [GitHubWorkItem] attribute, so the skip is tracked.
  • The other review threads (null check on m_presenter, double key handling, nested ifs in UpdateAutomationSizeAndPosition) were settled by your earlier replies.
  • Screenshot differences: the 252 and 259 changed screenshots include pages unrelated to MenuBar (Buttons, BreadcrumbBarPage, Basics). That looks like baseline noise, but I haven't compared it to the base build. Please check against the base before merging.

Not verified: I reviewed by inspection only. I did not build or run tests, and I made no code changes.

@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 248359 found UI Test snapshots differences: skia-linux-screenshots: 221, skia-windows-screenshots: 256

Details
  • skia-linux-screenshots: 221 changed over 2504

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AnimatedBackVisualSourceSamplePage.png-dark
    • AnimatedBackVisualSourceSamplePage.png
    • BenchmarkDotNet.png-dark
    • BenchmarkDotNet.png
    • Basics.png-dark
    • Basics.png
    • Border_CornerRadius_Binding.png-dark
    • Border_CornerRadius_Binding.png
    • BreadcrumbBarPage.png-dark
    • BreadcrumbBarPage.png
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • Buttons.png-dark
    • Buttons.png
    • Accessibility_Showcase.png-dark
    • Border_CornerRadius_BorderThickness.png-dark
    • Border_CornerRadius_BorderThickness.png
    • ClipboardTests.png-dark
    • ClipboardTests.png
    • AutomationProperties_StructureAndProps.png-dark
  • skia-windows-screenshots: 256 changed over 2504

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ButtonClippingTestsControl.png-dark
    • Buttons.png-dark
    • Accessibility_Showcase.png-dark
    • AutomationProperties_StructureAndProps.png-dark
    • AutomationProperties_StructureAndProps.png
    • Basics.png-dark
    • Basics.png
    • AutomationPropertiesExtensions_Role.png-dark
    • BasicAcrylicBrushTest2.png-dark
    • BasicAcrylicBrushTest2.png
    • Border_CornerRadius_BorderThickness.png-dark
    • Border_CornerRadius_BorderThickness.png
    • BreadcrumbBarPage.png-dark
    • BreadcrumbBarPage.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • ClipboardTests.png-dark
    • ClipboardTests.png
    • AutomationPropertiesExtensions_Role.png
    • AutomationProperties_AutomationId.png-dark

@MartinZikmund
MartinZikmund merged commit bbdec03 into master Nov 23, 2026
52 checks passed
@MartinZikmund
MartinZikmund deleted the dev/mazi/winui-sync-menubar branch November 23, 2026 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/automation Categorizes an issue or PR as relevant to project automation area/build Categorizes an issue or PR as relevant to build infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants