Skip to content

fix(commandbar): Settle open when reopened from Closed - #26718

Open
Xiaoy312 wants to merge 3 commits into
masterfrom
dev/xygu/20261124/fix-commandbar-reopen-loop
Open

Xiaoy312 wants to merge 3 commits into
masterfrom
dev/xygu/20261124/fix-commandbar-reopen-loop

Conversation

@Xiaoy312

@Xiaoy312 Xiaoy312 commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

GitHub Issue: closes #24671

PR Type:

🐞 Bugfix

What changed? 🚀

Reopening a CommandBar from its own Closed handler (which WinUI's CommandBar::OnClosedImpl explicitly supports) made it flip open and closed in a tight loop. Closed fired hundreds of times before the bar settled open.

The cause was an Uno-only handler on the overflow popup's Closed event that queued IsOpen = false at idle priority on every popup close, including the close that CommandBar.OnClosed itself performs. That queued close undid the app's reopen and started the cycle again. WinUI has no such handler.

This PR removes it. Clicking outside the bar still closes it: PopupPanel already routes an outside press to CommandBar.TryDismissInlineAppBarInternal().

Behavior change, now matching WinUI: unloading an open bar no longer closes it. Before, the popup closing on unload triggered the removed handler, which set IsOpen = false and raised Closed. Now IsOpen stays set, and the overflow reopens when the bar is loaded again (AppBar.OnLoaded).

Other ways of closing the overflow popup directly, without going through the bar, also leave IsOpen set: VisualTreeHelper.CloseAllPopups (internal, used by tests), re-applying the template while the bar is open, and UI Automation's Close on the popup. WinUI has the same gap.

Tests

  • Given_CommandBar.When_Reopened_From_Closed_Handler_Then_Settles_Open: Closed fires once and the bar and its overflow popup end up open.
  • Given_CommandBar.When_Unloaded_While_Open_Then_Reopens_On_Reload: IsOpen survives unload with no Closed, and the popup reopens on reload.
  • Given_CommandBar.When_Escape_Pressed_In_Overflow_Then_Closes: Escape with focus in the overflow closes the bar and its popup. It's excluded on native WinUI, where the test keyboard helper sends no keys.
  • Given_CommandBar.When_Popup_Open_Then_Click_Outside now also checks that clicking outside resets IsOpen, since that's the only remaining way an outside click reaches the bar.
  • The reopen test also checks that button labels aren't left compact.

Validation

  • Negative control: with the fix reverted, both tests fail on Skia Desktop: 582 Closed calls, and IsOpen reset on unload.
  • Skia Desktop (Release), with the fix: Given_CommandBar and CommandBarIntegrationTests ran 48 tests with 0 failures. That includes ValidateInlineCommandBarLightDismissBehavior, which covers closing the bar by clicking outside it.
  • Native WinUI (WinAppSDK): the reopen and unload tests pass. The Escape and click-outside tests don't run there.
  • Not run on WASM, Android or iOS.

PR Checklist ✅

🤖 Generated with Claude Code

Xiaoy312 and others added 2 commits November 24, 2026 18:51
The Uno-only overflow popup Closed hook queued IsOpen = false on every
popup close, including the one CommandBar.OnClosed performs itself, so
an app reopening the bar from its Closed handler was closed again in a
loop. WinUI has no such hook, and light-dismiss already reaches the
CommandBar through PopupPanel.

Unloading an open bar no longer closes it either: IsOpen stays set and
the overflow reopens when the bar is loaded again, as in WinUI.

Fixes #24671

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Unloading an open CommandBar closes its overflow popup but leaves
IsOpen set, so the bar reopens when it is loaded again, as in WinUI.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Xiaoy312
Xiaoy312 marked this pull request as ready for review November 25, 2026 16:25
Check that clicking outside and pressing Escape in the overflow both
reset IsOpen, and that reopening from Closed leaves the labels
uncompacted.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@mergify

mergify Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue). If it does not match the queue conditions yet, it enters the queue once it does.

  • Queue this pull request once it meets the queue conditions

@Xiaoy312
Xiaoy312 enabled auto-merge November 25, 2026 16:37
@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 249074 found UI Test snapshots differences: skia-linux-screenshots: 213, skia-windows-screenshots: 321

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

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Accessibility_Showcase.png
    • AnimatedBackVisualSourceSamplePage.png-dark
    • AnimatedBackVisualSourceSamplePage.png
    • AnimatedVisualsTestbedPage.png-dark
    • AutomationProperties_StructureAndProps.png-dark
    • AutomationProperties_StructureAndProps.png
    • Basics.png-dark
    • Basics.png
    • Border_CornerRadius_Binding.png-dark
    • Border_CornerRadius_Binding.png
    • Border_CornerRadius_BorderThickness.png-dark
    • Border_CornerRadius_BorderThickness.png
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • Accessibility_Showcase.png-dark
    • AnimatedVisualsTestbedPage.png
    • AutomationProperties_AutomationId.png
    • BasicAcrylicBrushTest.png-dark
    • BasicAcrylicBrushTest.png
    • Buttons.png-dark
  • skia-windows-screenshots: 321 changed over 2504

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AnimatedVisualsTestbedPage.png-dark
    • ClipboardTests.png-dark
    • ClipboardTests.png
    • AnimatedBackVisualSourceSamplePage.png
    • BenchmarkDotNet.png-dark
    • BenchmarkDotNet.png
    • AnimatedBackVisualSourceSamplePage.png-dark
    • AutomationProperties_AutomationId.png-dark
    • AutomationProperties_AutomationId.png
    • BasicAcrylicBrushTest2.png-dark
    • BasicAcrylicBrushTest2.png
    • Border_CornerRadius_Binding.png-dark
    • Border_CornerRadius_Binding.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • ColorPickerSample.png-dark
    • ColorPickerSample.png
    • CompositionNineGridBrush_Source_Changes.png-dark
    • CompositionNineGridBrush_Source_Changes.png
    • CornerRadiusControls.png-dark

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.

CommandBar oscillates open/closed when reopened from its own Closed handler

3 participants