Repository navigation
Conversation
Fixes WordPress#78355 The Escape key handler in handleMenuKeydown was gated on menuOpenedBy.click, so submenus opened via pointer hover could not be dismissed with Escape. This violates WCAG 1.4.13 (Content on Hover or Focus), which requires that hover-triggered content can be dismissed without moving the pointer. Move the Escape branch outside the click conditional and also call closeMenu( 'hover' ), so the key closes the submenu regardless of how it was opened. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
|
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. |
|
👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @Gilmoursa! In case you missed it, we'd love to have you join us in our Slack community. If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information. |
Closes #78355
What?
Move the Escape key handler in
handleMenuKeydownoutside of themenuOpenedBy.clickconditional, and also callcloseMenu( 'hover' ), so that hover-opened submenus are dismissed when the user presses Escape.Why?
The Escape branch in
handleMenuKeydownwas gated onstate.menuOpenedBy.click. When a submenu was opened via pointer hover,menuOpenedBy.hoverwas set butmenuOpenedBy.clickwas not, so the Escape key did nothing.This violates WCAG 1.4.13 — Content on Hover or Focus, which requires that content triggered by hover can be dismissed without moving the pointer or keyboard focus.
How?
In
packages/block-library/src/navigation/view.js, thehandleMenuKeydownaction previously looked like:The Escape check is moved before the
clickgate and extended to also close the hover state:The Tab focus-trap logic remains gated on
menuOpenedBy.clicksince it only applies to the click-opened overlay menu.Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast
This fix affects hover-dismiss behavior on the front end. No editor UI change.
Use of AI Tools
This pull request was developed with assistance from Claude (Anthropic). Claude identified the root cause, implemented the fix, and verified it against the existing test suite. The change was reviewed before submission per the WordPress AI Guidelines.