Navigation submenus: avoid to focus the submenu trigger button when submenu loses focus #41975
Labels
[Block] Navigation
Affects the Navigation Block
[Focus] Accessibility (a11y)
Changes that impact accessibility and need corresponding review (e.g. markup changes).
Description
#41774 introduced a couple changes for the navigation submenu keyboard interaction.
1 Close the submenu when pressing the Escape key: makes perfectly sense and works as expected.
2 Always move focus to the submanu trigger button when the submenu loses focus, such as tabbing out of it.
The second change triggers a few unexpected behaviors that are pretty confusing for both mouse and keyboard users.
Step-by-step reproduction instructions
1
Focus moves to the trigger when focusing any other interactive element on the page.
This "jumping back' may happen with any other focusable element on the page. The first animated GIF attached below tries to better illustrate the problem. Note: I used a red outline for the focus style, to make things clearer.
2
Focus is moved to the next trigger when tabbing backwards to the previous menu item.
The 'focus trigger' behavior is pretty confusing when tabbing backwards:
Overall, I'm not sure there's a reliable way to move focus to the trigger when the submenu loses focus. I'd suggest to keep only the 'focus on Escape' behavior.
Screenshots, screen recording, code snippet
Animated GIF to illustrate what happens when focusing any other interactive element on the page:
Animated GIF to illustrate what happens when tabbing backwards:
Environment info
No response
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
The text was updated successfully, but these errors were encountered: