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. |
t-hamano
left a comment
There was a problem hiding this comment.
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?
previousFocusto the context (Interactivity API) of submenus. This makes each level have it’s own reference. Without this onepreviousFocusreference is shared by all levels and when set by a nested menu it overwrites the previous value causing it to be lost.stopPropagationcall to thekeydownhandler (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