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

Library: revisit keyboard navigation for pattern items #52009

Closed
talldan opened this issue Jun 28, 2023 · 8 comments
Closed

Library: revisit keyboard navigation for pattern items #52009

talldan opened this issue Jun 28, 2023 · 8 comments
Labels
[Feature] Patterns A collection of blocks that can be synced (previously reusable blocks) or unsynced [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). Needs Accessibility Feedback Need input from accessibility

Comments

@talldan
Copy link
Contributor

talldan commented Jun 28, 2023

Description

The template part and pattern listings in the Library are implemented using Composite and CompositeItem components. The way this works is that the entire list is a single tab stop. Up and down arrow keys are used to navigate. The list implements a roving tab index, so when tabbing out of the list and back in again, the previously focused item (not the first focusable item) will be focused.

The problem is that each pattern item in the Custom Patterns category also has an 'Actions' dropdown menu, which is another tab stop within the list. That interferes with the way keyboard navigation is supposed to work—the roving tab index wouldn't be restored correctly, and it would be extremely challenging to interact with the dropdown.

A quick fix was applied when shipping the original library PR:

  • The dropdown menu was made not focusable using the keyboard and aria-hidden.
  • A separate Delete key shortcut was added to ensure that patterns could still be deleted using the keyboard (this was the only action available in the dropdown).

This approach isn't particularly scalable. As more actions are added to the dropdown, more shortcuts also need to be added to cover each of the actions. Users also need to be made aware of what the special shortcuts are.

Some possible options (pick one):

  • Reconsider the keyboard navigation model used in the library, are there other more appropriate options?
  • Instead of adding individual shortcuts for each action, implement one shortcut that can be used to open the 'Actions' dropdown when a pattern is focused.
  • Keep the current system with multiple keyboard shortcuts, but find a way to make them easily discoverable

It'd be great to hear any other ideas.

Step-by-step reproduction instructions

  1. Open the site editor
  2. Tab to the 'Library' option in the navigation region and select it
  3. Tab to the Custom patterns option in the navigation region and select it
  4. Use the navigate regions shortcut to switch to the 'Library content' region
  5. Tab till you get to the Patterns list box and navigate

Screenshots, screen recording, code snippet

Screen Shot 2023-06-28 at 12 19 36 pm

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

@talldan talldan added [a11y] Keyboard & Focus [Feature] Patterns A collection of blocks that can be synced (previously reusable blocks) or unsynced labels Jun 28, 2023
@talldan talldan added the Needs Accessibility Feedback Need input from accessibility label Jun 28, 2023
@talldan
Copy link
Contributor Author

talldan commented Jun 28, 2023

I think my preferred pragmatic option would be replacing the 'delete' shortcut with a single keyboard shortcut for opening the actions menu (I'm not sure what the best shortcut key would be. Possibly the 'A' key).

Maybe the simplest implementation is trigger a 'click' event on the dropdown menu button, as I don't think there's a 'controlled' way to open a DropdownMenu component.

@annezazu
Copy link
Contributor

@alexstine @joedolson @afercia could you all perhaps provide feedback here?

@alexstine
Copy link
Contributor

The problem is, discoverability. Why not implement TreeGrid component here similar to the list view?

@talldan
Copy link
Contributor Author

talldan commented Jun 29, 2023

@alexstine The items aren't a tree, but a normal linear list. I guess that would be a grid pattern? For keyboard navigation it would probably be very similar to List View, just without the depth/nesting aspect.

@alexstine
Copy link
Contributor

@talldan I was just thinking, that same keyboard experience, that would work perfectly for this the way you describe it.

@afercia
Copy link
Contributor

afercia commented Jul 4, 2023

I noticed this in another issue and commented:

I'd reconsider the listbox / options implementation as it introduces unnecessary complex interaction for screen reader users. This is just a list of objects, visually presented in a grid. I'd recommend to use a standard list.

Also, in ARIA a listbox is something pretty different and it's more something close to a select with multiple selection, see https://www.w3.org/WAI/ARIA/apg/patterns/listbox/

I'd strive for simplicity and also avoid a treegrid or a grid. Why not use a simple list, where each item has a button that shows the available actions?

@glendaviesnz
Copy link
Contributor

I'd strive for simplicity and also avoid a treegrid or a grid. Why not use a simple list, where each item has a button that shows the available actions?

@afercia I have a PR here that moves this to a basic tabable ul - do you have time to give this a review please?

@glendaviesnz
Copy link
Contributor

I think the main issues outlined here have been resolved by the move to a simple ul so closing this for now.

@priethor priethor added [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). and removed [a11y] Keyboard & Focus labels Jul 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Patterns A collection of blocks that can be synced (previously reusable blocks) or unsynced [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). Needs Accessibility Feedback Need input from accessibility
Projects
None yet
Development

No branches or pull requests

6 participants