-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Navigation block: fix submenu Escape key behavior #69837
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 block: fix submenu Escape key behavior #69837
Conversation
Size Change: +6 B (0%) Total Size: 1.84 MB
ℹ️ View Unchanged
|
Flaky tests detected in 07142c2. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/14287716831
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
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 for the fix! This PR works very well for me.
Testing keyboard accessibility with screen reader:
1baacce029df89a60ed8ed6c5ea05355.mp4
Thanks for the review 🙇. I was glad to see your testing included third-level menus and with “Open on click” disabled. |
* Add coverage in e2e tests * Fix focus loss when pressing Escape from nested menu * Update e2e test for closing one menu level * Have Escape key close a single menu level at a time Co-authored-by: stokesman <presstoke@git.wordpress.org> Co-authored-by: t-hamano <wildworks@git.wordpress.org>
What?
Closes #69834
When using the Escape key to close menus, this makes it only close one menu level at a time and focus the parent menu item.
Why?
When using the Escape key to close menus:
How?
previousFocus
to the context (Interactivity API) of submenus. This makes each level have it’s own reference. Without this onepreviousFocus
reference is shared by all levels and when set by a nested menu it overwrites the previous value causing it to be lost.stopPropagation
call to thekeydown
handler (when Escape key was pressed).Testing Instructions
Manually
Use the following HTML to create a Navigation with nested submenus:
HTML example
E2E
Screenshots or screencast