Skip to content
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: avoid to focus the submenu trigger button when submenu loses focus #41975

Closed
afercia opened this issue Jun 27, 2022 · 0 comments · Fixed by #41986
Closed
Assignees
Labels
[Block] Navigation Affects the Navigation Block [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes).

Comments

@afercia
Copy link
Contributor

afercia commented Jun 27, 2022

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.

  • Test a page with other interactive elements, for example the Hello World post with comments enabled will show the comment form at the end of the page.
  • Use the keyboard to move to the navigation menu and open a submenu.
  • Leave the submenu open.
  • Scroll the page and click within the comment textarea.
  • This step can be performed also by screen reader users, directly jumping from the menu item to the comment textarea via dedicated keyboard shortcuts.
  • Once the comment textarea receives focus, the new behavior will move focus back to the open submenu trigger:
    • Visually: the page will scroll up unexpectedly.
    • The comment textarea is not focused any longer.
    • Keyboard users and screen reader users will be catapulted back to the submenu, which is likely placed several tab stops before the comment textarea.

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:

  • Use the keyboard to move to the navigation menu and open a submenu.
  • Press Tab to focus one of the the submenu items.
  • Press Shift + Tab to move focus back to the submenu trigger.
  • Press Shift + Tab again to move focus back to the menu item the trigger belongs to.
  • Press Shift + Tab again.
  • At this point, focus will jump forward to the next menu item trigger, which is unexpected and pretty confusing for users.
  • Note that this happens also with nested submenus.

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:

jump-to-form-

Animated GIF to illustrate what happens when tabbing backwards:

tab-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

@afercia afercia added [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Block] Navigation Affects the Navigation Block labels Jun 27, 2022
@alexstine alexstine self-assigned this Jun 27, 2022
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Jun 27, 2022
@priethor priethor removed the [Status] In Progress Tracking issues with work in progress label May 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Navigation Affects the Navigation Block [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes).
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants