Skip to content

fix(controls): fix radio MenuItem grouping in MenuFlyout - #21356

Merged
MrJul merged 2 commits into
AvaloniaUI:masterfrom
zrt2399:main
May 14, 2026
Merged

fix(controls): fix radio MenuItem grouping in MenuFlyout#21356
MrJul merged 2 commits into
AvaloniaUI:masterfrom
zrt2399:main

Conversation

@zrt2399

@zrt2399 zrt2399 commented May 13, 2026

Copy link
Copy Markdown
Contributor

What does the pull request do?

fix #21355

What is the current behavior?

What is the updated/expected behavior with this PR?

How was the solution implemented (if it's not obvious)?

MenuFlyout radio MenuItems were not participating in radio group updates
the same way as ContextMenu items.

When MenuItems are hosted in a MenuFlyout, they may rely on the visual tree
to find their owning MenuBase/interaction handler after realization. As a
result, radio items could stay checked instead of unchecking other items in
the same group.

This change:

  • adds a visual-tree fallback when resolving MenuItem interaction handlers
  • registers radio MenuItems when they attach to the visual tree
  • guards RadioButtonGroupManager against duplicate registrations
  • adds a regression test covering MenuFlyout radio group behavior

This fixes the case where grouped radio MenuItems inside MenuFlyout do not
behave mutually exclusively, while the equivalent ContextMenu setup works.

Checklist

Breaking changes

Obsoletions / Deprecations

Fixed issues

fix #21355

@MrJul MrJul added bug backport-candidate-12.0.x Consider this PR for backporting to 12.0 branch labels May 13, 2026
@avaloniaui-bot

Copy link
Copy Markdown

You can test this PR using the following package version. 12.1.999-cibuild0065347-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@MrJul MrJul left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!

@MrJul
MrJul added this pull request to the merge queue May 14, 2026
Merged via the queue into AvaloniaUI:master with commit 60db99a May 14, 2026
12 checks passed
MrJul pushed a commit to MrJul/Avalonia that referenced this pull request May 28, 2026
@MrJul MrJul added backported-12.0.x and removed backport-candidate-12.0.x Consider this PR for backporting to 12.0 branch labels May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RadioMenuItems cannot be grouped in MenuFlyout

3 participants