Skip to content

a11y: add arrow key navigation to Tabs - #104

Open
aroberts957 wants to merge 1 commit into
OpenNSWM-Lab:mainfrom
aroberts957:fix/tabs-arrow-keys
Open

a11y: add arrow key navigation to Tabs#104
aroberts957 wants to merge 1 commit into
OpenNSWM-Lab:mainfrom
aroberts957:fix/tabs-arrow-keys

Conversation

@aroberts957

Copy link
Copy Markdown

This PR implements the WAI-ARIA tabs keyboard navigation pattern for the Tabs component in frontend/src/components/ui/tabs.tsx.

What changed:

  1. TabsList now has role=tablist, which was missing. This is required by the ARIA tabs pattern and lets assistive tech identify the tab strip.

  2. TabsTrigger gains an onKeyDown handler that responds to ArrowLeft and ArrowRight. When pressed, focus wraps cyclically through the sibling tabs (ArrowLeft goes to the previous tab, wrapping from first to last; ArrowRight goes to the next, wrapping from last to first). The handler also triggers click on the focused tab so selection follows focus.

Why this matters:

Without arrow key navigation, keyboard users can only reach tabs by tabbing through every element on the page. The WAI-ARIA Authoring Practices Guide specifies that tab lists should support ArrowLeft/ArrowRight for moving between tabs. This brings the component in line with that spec (WCAG 2.1.1 Keyboard).

Verification:

The diff is limited to tabs.tsx. The handleKeyDown handler queries the closest tablist ancestor to find sibling tabs, so it works regardless of how many TabsTrigger instances are rendered. Focus wrapping uses modular arithmetic to cycle correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant