-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[Menubar] Adds keyboard behaviors to the menubar, improves accessibility #3320
base: develop
Are you sure you want to change the base?
[Menubar] Adds keyboard behaviors to the menubar, improves accessibility #3320
Conversation
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.
- Extract logo to header level for better semantic structure
- Ensure arrow keys only cycle through menu items, excluding the logo
…w on an unopened submenu
import usePrevious from '../../common/usePrevious'; | ||
|
||
/** | ||
* @component |
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 love the addition of documentation for the components!
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.
Thanks so much for continuing the work on the navigation menu section—I really love the transformation you've been giving it!
I think overall this PR looks great so far! I feel like there's also a few great practices that are being introduced here (such as the formatting of the PR, component documentation, more detailed commenting) that could be adopted throughout the codebase as well! I also agree that this is a good point to stop at for this PR, and the rest of the tasks outlined in the description could be addressed in future ones.
I think the only issue I might've found is that I noticed that when using the arrow keys to navigate specifically the File SubMenu, it ends up skipping over "Open".
nav_file_menu.mov
Besides this, I mostly had a few questions while testing it out and looking through the code, which I'll list out below!
- When navigating the SubMenus, I noticed that both the mouse hover and arrow key inputs are visible, which I tried to depict in the video. I feel like this could get a bit confusing, but unsure if it might've been intentional!
nav_language_menu.mov
- I also noticed that the focus state immediately appears on the Menubar as soon as I landed on the editor page. I was wondering if this might've been intended as well!

-
I know there's a few different opinions around adding comments, I was curious about why you decided to add more explanatory comments throughout the components!
-
While looking through
MenubarSubmenu.jsx
, I feel like it could be broken down into maybe a few files, but was wondering if you felt that way as well!
Fixes #2933
Just setting this up to track next steps for the component! This PR focuses on adding proper keyboard behaviors to the recently refactored Menubar. Currently in progress
Update
The Menubar component now has keyboard navigation and enhanced accessibility support. There are some other improvements to make which are listed at the end, but I'll implement them in future PRs seeing as this one has gotten rather large.
Before:
Navigation happened purely through Tab / Shift + Tab. Escape functionality worked but otherwise behaviors were not intuitive or accessible. Focus is not tied to state.
old_menubar_2.mov
After:
Most keyboard behaviors from the WAI ARIA authoring guide implemented. Tab behavior works as expected and initial focus styles are available.
menubar_test.mov
Key Changes
Menubar.jsx
for focus managementaria-orientation='horizontal'
onMenubar
and aria-labels where applicableMenubar
innav
elementdiv
-based menubar toul/li
Logo
is moved outside of thenav
,UserMenu
is back inul
elements withrole=group
SubmenuContext
for managing submenu stateMenubarSubmenu
supportslistbox
aria roles, such as with the options inLanguageMenu
To Do
menuItems
andmenuItemToId
could probably be combined into a better data structureuseReducer
I have verified that this pull request:
npm run lint
)npm run test
)develop
branch.Fixes #123