Menu buttons: Clicking on a subMenuProp (dropdown in a command bar) and then pressing enter key, by default selects the first index and invoke its's click event.
Bug Report
Command Bar- Clicking on a subMenuProp (dropdown in a command bar) and then pressing enter key, by default selects the first index and invoke its's click event.
- Package version(s): ^0.87.1
- Browser and OS versions: NA
Describe the issue:
Repro steps: 1.) Click on the dropdown under command bar 2.) None of the child elements look selected acc to UI. (None of them are shadowed/greyed) 3.) Press enter. The first child element's click event is triggered even when it was not selected as per the UI.
Actual behavior:
First child is selected but not shown selected properly. //Click dropdown in Command bar (subMenuProps containing child items)
Expected behavior:
Either the first element should be shown as selected or pressing enter after clicking should not trigger first element's click event
If applicable, please provide a codepen repro:
This is a really interesting one. It is technically by design. When you click a menu, we set focus to the first item in the submenu, but we hide the focus rectangle until you press a keystroke. We do this for accessibility reasons; screen readers read out the menu item as things are focused.
What you're asking is; if mouse click, don't set focus on the first item. Instead, keep the focus on the first item. If enter is pressed, it would toggle the menu closed. If you press down arrow, it would focus the first item. This would address your issue but probably cause accessibility concerns.
But I also think the keyboarding path may be different. If you press enter to expand a command bar menu rather than clicking, I think you do want the focus to jump to the first menu item. Then you can hit enter twice to just execute the first menu item.
@cschlechty and @betrue-final-final do you have any thoughts here? After playing with some other menu systems, I think they follow the model I described above. However it could affect screen readers if the user clicks on a menu expanding it, it would not read the first item until they down arrow.
I've discussed this with accessibility and design; I think we will try to address this to perfect the interaction model. We will only move focus on keyboarding; on mouse clicks, we will maintain focus at the command clicked.
I'd be inclined to follow the pattern Windows uses. Let's not reinvent menu interactions.
I thought that this was a pretty intentional choice. It shouldn't be that hard to change it so that it focuses the list rather than the first item.
As far as I understand it correctly, you are trying to bring the focus on the list rather than the first time in the scenario i have mentioned. Can we get an ETA for this?
@dzearing Hi, any update on this? I see an attached bug getting closed. Is this related to that one?
We should keep focus on command bar and only move focus to the menu on down arrow.
@dzearing is this resolved?
We are shipping a refactored command bar in 6.0. We can test it in that one, but I haven't touched this code in a while.
This issue has been automatically marked as stale because it has not activity for 30 days. It will be closed if no further activity occurs within 14 days of this comment. Thank you for your contributions to Fabric React! Why am I receiving this notification?
@dzearing Was this addressed in 6.0? If so, can we close?
this has been fixed in the 6.0 version. Clicking on a dropdown doesn't set the first item as infocus. This is consistent with windows UI.
