Repository navigation
fix: RadioMenuFlyoutItem deselect when initial IsChecked set in XAML - #23240
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes RadioMenuFlyoutItem group deselection when IsChecked="True" is applied from XAML before GroupName (issue #19090) by re-registering the checked item once it’s loaded, and adds a runtime test that reproduces the attribute-order scenario. It also syncs RadioMenuFlyoutItem / MenuFlyout theme resources to WinUI 3 equivalents and removes legacy per-contract XAML resource revisions.
Changes:
- Add
Loaded/Unloadedhandlers toRadioMenuFlyoutItemto re-register checked items after XAML property application and to deterministically clean up group tracking. - Replace legacy
RadioMenuFlyoutItemandMenuFlyouttheme resource XAML revisions with WinUI 3-aligned theme resources. - Add a runtime test reproducing the XAML attribute-order bug (
IsCheckedbeforeGroupName).
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Uno.UI/UI/Xaml/Controls/RadioMenuFlyoutItem/RadioMenuFlyoutItem.Properties.cs | Updates WinUI/MUX reference commit metadata. |
| src/Uno.UI/UI/Xaml/Controls/RadioMenuFlyoutItem/RadioMenuFlyoutItem.cs | Adds Loaded/Unloaded handling and changes group-selection map storage to fix XAML attribute order behavior. |
| src/Uno.UI/UI/Xaml/Controls/RadioMenuFlyoutItem/RadioMenuFlyoutItem_themeresources.xaml | Replaces theme resources with WinUI 3-aligned styles/templates. |
| src/Uno.UI/UI/Xaml/Controls/RadioMenuFlyoutItem/RadioMenuFlyoutItem_rs1_themeresources_v1.xaml | Removes legacy theme resource revision. |
| src/Uno.UI/UI/Xaml/Controls/RadioMenuFlyoutItem/RadioMenuFlyoutItem_rs2_themeresources_v1.xaml | Removes legacy theme resource revision. |
| src/Uno.UI/UI/Xaml/Controls/RadioMenuFlyoutItem/RadioMenuFlyoutItem_rs4_themeresources_v1.xaml | Removes legacy theme resource revision. |
| src/Uno.UI/UI/Xaml/Controls/RadioMenuFlyoutItem/RadioMenuFlyoutItem_rs5_themeresources_v1.xaml | Removes legacy theme resource revision. |
| src/Uno.UI/UI/Xaml/Controls/MenuFlyout/MenuFlyout_themeresources.xaml | Adds WinUI 3-aligned MenuFlyout theme resources/styles/templates. |
| src/Uno.UI/UI/Xaml/Controls/MenuFlyout/MenuFlyout_19h1_themeresources.xaml | Removes legacy theme resource revision. |
| src/Uno.UI/UI/Xaml/Controls/MenuFlyout/MenuFlyout_rs1_themeresources.xaml | Removes legacy theme resource revision. |
| src/Uno.UI/UI/Xaml/Controls/MenuFlyout/MenuFlyout_rs2_themeresources.xaml | Removes legacy theme resource revision. |
| src/Uno.UI/UI/Xaml/Controls/MenuFlyout/MenuFlyout_rs4_themeresources.xaml | Removes legacy theme resource revision. |
| src/Uno.UI/UI/Xaml/Controls/MenuFlyout/MenuFlyout_rs5_themeresources.xaml | Removes legacy theme resource revision. |
| src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_RadioMenuFlyoutItem.cs | Adds a runtime test that reproduces the XAML attribute-order issue. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23240/wasm-skia-net9/index.html |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23240/wasm-skia-net9/index.html |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23240/wasm-skia-net9/index.html |
|
|
) When IsChecked="True" appears before GroupName in XAML attribute order, the item was registered in the selection map under the empty group name because GroupName was still its default value when IsChecked was applied. A subsequent click on a sibling could not find the previously-checked item under the real group name, so it was never unchecked. Port the WinUI 3 OnLoaded handler that re-runs UpdateCheckedItemInGroup once all XAML-applied properties are set. Also replace the unsafe C# finalizer with a deterministic OnUnloaded handler that mirrors WinUI's. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Replace the WinUI 2.6-era theme resources with a verbatim 1:1 copy of the latest WinUI 3 source (commit 69097129a8). Drop the four legacy _rsX_themeresources_v1.xaml fallbacks, which targeted Win10 OS API contracts and were superseded by the modern file at merge time. Also bumps the Properties.cs MUX reference to the matching commit. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Replace the five legacy WinUI 2.x revisions (19h1, rs1, rs2, rs4, rs5) with a verbatim 1:1 copy of the latest WinUI 3 source (commit 9d6fb15c08). This brings MenuFlyoutPresenter, MenuFlyoutItem, MenuFlyoutSubItem, ToggleMenuFlyoutItem and SplitMenuFlyoutItem styles in line with current WinUI, including the MenuFlyoutItemTextTrimming resource that the synced RadioMenuFlyoutItem template now references. Two Uno-specific extras from the legacy files are intentionally dropped: - not_win:Glyph="" SubItemChevron override (was in rs5) - LanguageSwitcherMenuFlyoutItemPlaceholderThemeThickness (was in 19h1) Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
When IsChecked is applied before GroupName (the common case being the XAML attribute order IsChecked="True" GroupName="..."), the item ends up registered in s_selectionMap under both the previous (default "") key and the new key. The stale "" entry is never cleaned up, so an unrelated RadioMenuFlyoutItem in the default empty group can incorrectly uncheck this item when it becomes checked. Track the GroupName actually used at registration time and erase the prior entry (only when it still targets this instance) before re-registering; also use the same key in OnUnloaded so we never remove another item's registration. Wrapped in #if HAS_UNO since the same gap exists upstream; tracked at microsoft/microsoft-ui-xaml#11098. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Excluded until upstream microsoft-ui-xaml#11098 is fixed. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
c551400 to
b57c52b
Compare
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23240/wasm-skia-net9/index.html |
|
|
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23240/wasm-skia-net9/index.html |
GitHub Issue: closes #19090
PR Type:
🐞 Bugfix
What changed? 🚀
The bug
When a
RadioMenuFlyoutItemhadIsChecked="True"set in XAML beforeGroupNamein the attribute order (as in the repro from #19090), clicking another item in the same group did not uncheck the originally-checked item — the group selection was effectively impossible to change.Root cause
RadioMenuFlyoutItemkeeps a thread-statics_selectionMapkeyed by group name. When XAML appliedIsChecked="True"first,GroupNamewas still its default empty string, so the item registered itself in the map under"". By the time the user clicked a sibling, lookups by the real group name found nothing and skipped the unchecking step.The Uno port was synced from a WinUI 2.6-era commit and was missing the
OnLoadedhandler that WinUI added later precisely for this scenario. WinUI'sOnLoadedre-runsUpdateCheckedItemInGroup()once all XAML-applied properties (includingGroupName) are guaranteed to be set, fixing the registration.The fix
OnLoadedhandler that re-registers the checked item under its realGroupName.OnUnloadedhandler matching WinUI'sOnUnloaded(the finalizer was unsafe — C# finalizers run on the GC thread and can't reliably touch UI state).Given_RadioMenuFlyoutItem.When_IsChecked_Set_Before_GroupName_In_Xamlruntime test that mirrors the issue's exact XAML. Verified to fail before the fix and pass after.Bonus: WinUI 3 style sync
Folded in alongside the fix while in the area:
RadioMenuFlyoutItem_themeresources.xaml: replaced with verbatim 1:1 copy of WinUI 3 (commit69097129a8). Drops the four legacy_rsX_themeresources_v1.xamlWin10 OS-contract fallbacks that were superseded at merge time.MenuFlyout_themeresources.xaml: replaced the five legacy WinUI 2.x revisions (19h1,rs1,rs2,rs4,rs5) with a verbatim 1:1 copy of WinUI 3 (commit9d6fb15c08). BringsMenuFlyoutPresenter/MenuFlyoutItem/MenuFlyoutSubItem/ToggleMenuFlyoutItem/SplitMenuFlyoutItemstyles in line with current WinUI.Two minor Uno-specific extras from the legacy MenuFlyout files are intentionally dropped: the
not_win:Glyph=""SubItemChevron override (was inrs5) and theLanguageSwitcherMenuFlyoutItemPlaceholderThemeThicknessresource (was in19h1).PR Checklist ✅
Screenshots Compare Test Runresults.