grommet / hpe-design-system

HPE Design System
48 stars 24 forks source link

Keyboard Navigation Behavior (Arrow key vs Tab) #2664

Open jcfilben opened 2 years ago

jcfilben commented 2 years ago

Currently on Grommet we have a mix of components that use arrow keys to navigate and some components that use tab to navigate. There are also components that leave the focusIndicator on the container, components that have the focusIndicator on items within the container, and components that don't show a focusIndicator.

It would be great to gain more clarity on what the correct accessibility behavior is.

Tab based navigation components:

Arrow key based navigation components:

Supports both:

jcfilben commented 1 month ago

Related to discussions in https://github.com/grommet/grommet/issues/5677

jcfilben commented 1 month ago

Adding notes from Chat GPT prompts on this topic...

1. Tab Key Navigation

2. Arrow Key Navigation

3. Why Tab and Arrow Keys Are Not Interchangeable

4. Communicating the Rationale

5. Draft Rule (for Testing)


When using arrow key based navigation in a component should the focus indicator remain on the container or be placed on the individual item within the component?

Answer:

The focus indicator should generally be placed on the individual item within the component rather than the container. Here’s why:

Clear Selection: Placing the focus indicator on the individual item helps users easily see which item is currently selected, especially when navigating through lists or grids.

Intuitive Navigation: Users expect the focus to move with the arrow keys. Highlighting the item directly conveys that the selection has changed.

Accessibility: This approach supports screen reader users and those relying on keyboard navigation, making it clear which specific element is active.

Consistency: Keeping the focus indicator on items aligns with common UI patterns, making it familiar and intuitive for users.

In summary, the focus should be on the individual items to enhance usability and accessibility.

SmWorkGitHub commented 1 month ago

Hi @jcfilben. @SOjaHPE showed this to me today. I filed an accessibility epic against the global header which is relevant to this. GLCP-176633

I detemined that Bill T has to navigate using arrow keys because they reads the UI text and tab stops in the global header don't provide enough context.

The global header, and the UI components I've worked with in the past, are designed for tab navigation between components and arrow navigation within components. The global header works great that way but is a nightmare when you navigate between components with arrow keys. The issue is that the tab stops have to provide good context for screen reader users.