-
Notifications
You must be signed in to change notification settings - Fork 459
[MenuButton] Accessibility fixes and allow custom button content #4093
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MenuButton] Accessibility fixes and allow custom button content #4093
Conversation
|
|
||
| protected override void OnParametersSet() | ||
| { | ||
| if (Text is not null && ButtonContent is not null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you need to test this. But you must add to the Text property that this property will be ignored if ButtonContent is defined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You cannot force the developer to have a content. The dev can create a MenuButton without content.
So, just add in the Text property comment: this property will be ignored if ButtonContent is defined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not correct with the new comment. You must remove this test: the dev can set a value in Text and ButtonContent. And the component will render only the ButtonContent (ignoring the Text prarameter).
…sible-no-require-icon' into adamint/fluent-menu-button-accessible-no-require-icon
|
@adamint Can you please finish this PR and fix the comments. Thanks. |
…sible-no-require-icon' into adamint/fluent-menu-button-accessible-no-require-icon
|
@vnbaaij updated based on comments. |
|
Ok, I realized that this issue is not unique to just menu buttons and was happening to all menus. I have reverted the focus changes to the Grabacion.de.pantalla.2025-09-09.a.la.s.5.37.40.p.m.mov |
…sible-no-require-icon' into adamint/fluent-menu-button-accessible-no-require-icon
|
|
||
| protected override void OnParametersSet() | ||
| { | ||
| if (Text is not null && ButtonContent is not null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You cannot force the developer to have a content. The dev can create a MenuButton without content.
So, just add in the Text property comment: this property will be ignored if ButtonContent is defined
|
Hi @adamint . Can we work to get this merged in. Please look at the latest open remarks. Thanks. |
|
|
||
| protected override void OnParametersSet() | ||
| { | ||
| if (Text is not null && ButtonContent is not null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not correct with the new comment. You must remove this test: the dev can set a value in Text and ButtonContent. And the component will render only the ButtonContent (ignoring the Text prarameter).
|
@adamint, just one more small change requested... |
dvoituron
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vnbaaij will update the PR comments in another PR.
Pull Request
📖 Description
I really like this component, but it's currently unusable in Aspire because it's not keyboard-accessible. To make it accessible, the menu button needs to properly handle tab (tab on button menu is open focuses first menu item, tab when focus is on a menu item will focus the next focusable dom element outside the menu + close the menu), and shift+tab (shift+tab when focus is on the button will close the menu if open, or otherwise will focus the button if a menu item is focused).
Additionally, the button content was not customizable (no render fragment could be provided).
This PR fixes both problems. I added a new parameter
ButtonContentthat can be provided instead ofText.The accessibility changes were implemented client-side because of the focusing logic requiring DOM access. I also had to fix the FluentAnchoredRegion's
FocusableElement.findNextFocusableElementfunction to support focusing fluent components that have focusable children (since they themselves are not focusable), which I reused in the FluentMenuButton. Please refer to this before and after:Before (see keys pressed on screen for context)
Grabacion.de.pantalla.2025-08-28.a.la.s.8.29.16.p.m.mov
After
Grabacion.de.pantalla.2025-08-28.a.la.s.8.30.51.p.m.mov
🎫 Issues
Fixes #4090
👩💻 Reviewer Notes
N/A
📑 Test Plan
I added a couple tests for the
ButtonContentparameter, but as most of the accessibility changes are in the component JS, you will need to test manually using the MenuButton sample page.✅ Checklist
General
Component-specific
⏭ Next Steps