-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Navigation submenus: Allow Escape key to close the submenu and focus trigger #41774
Conversation
Size Change: +223 B (0%) Total Size: 1.24 MB
ℹ️ View Unchanged
|
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.
Quick note.
I tested this and it adds the maybe related to this PR
unrelated to this PR
|
@draganescu My thoughts.
I don't think this is really an issue, actually, one could argue it should have been working like this all along. The code that handles this detects outside focus, the only thing I changed was adding the Escape key. As a result, the focus was necessary to prevent Escape key from closing the menu and focus getting trapped. If others think it is a big UX issue, I could always split out the functions and only focus on Escape key vs. loss of focus on the menu. |
We discussed this Pull Request during the weekly Accessibility Team's bug-scrub: discussion happened in the accessibility channel on Slack. |
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 works as described and fixes the problem. The one issue I found seems to be a non issue. Awesome 👏🏻
@alexstine maybe we could check if the focus is on an unrelated element (something unrelated to the menu) and not move the focus if that is true? Should be possible.
@draganescu I am sure we could but then it would not announce the closed state. If this was the case, users should reasonably expect to be able to Shift+Tab back to the open submenu only finding that it closed with no notification to them. I am not sure those UX would be any better. |
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.
Thank you for this PR. It works as described and the code looks good.
My apologies for the delay in reviewing.
Soon to become the most approved PR on Github 😂 |
Thanks for the reviews everyone! If there is any further questions about UX, happy to make adjustments should they be needed. |
Late to the party, but I noticed a couple issues with this change. |
What?
Adding the ability to close open submenus via Escape key and focus the submenu trigger.
Why?
For better accessibility.
How?
Modify the JS on the front-end.
Testing Instructions
aria-expanded
was removed and the submenu trigger should not have lost focus.Screenshots or screencast