CMSgov / design-system

Open source design and front-end development resources for creating Section 508 compliant, responsive, and consistent websites.
https://design.cms.gov
Other
309 stars 84 forks source link

Improve tab keyboard interactions #3113

Open maggiewachs opened 2 months ago

maggiewachs commented 2 months ago

This is really a usability improvement or enhancement, less so a bug :)

Describe the bug The tab component's implementation of keyboard support is somewhat non-standard:

To Reproduce Steps to reproduce the behavior:

  1. Go to https://data.cms.gov/provider-data/dataset/0ba7-2cb0
  2. Use the Tab key to access the tabs component (Data Table, Overview, API...)
  3. Tab/arrow to traverse the tabs -- notice that arrows automatically select a tab, while the Tab key requires that you make a selection with Enter
  4. Select the Overview tab
  5. Use the Tab key again -- focus should move to "Download full dataset" button, but instead moves to the API tab

Expected behavior Use a managed focus pattern for the tabs component, where the user can Tab key to the tab list and then use arrows to make a selection. The method for selection should probably be either auto-selection (as it does now with arrow keys) or manual selection (Enter or Space bar to choose a tab). Once a tab is selected, the next Tab key moves focus to the selected content; shift+Tab then moves focus back up to the tab list. Example: https://www.w3.org/WAI/ARIA/apg/patterns/tabs/examples/tabs-manual/

Desktop (please complete the following information):

Additional context It would probably help to include interactive elements in the tab examples, too, to show how focus moves.

zarahzachz commented 1 month ago

A ticket in Jira was created.

Part of the hold off on implementing these changes revolves around the potential for a Tab refactor.

Outstanding issues with the current Tab implementation: