Keyboard Navigator reference: Tab Order
In the kit: .github/skills/keyboard-navigator/references/tab-order.md.
-
This file as plain text, at
https://letitglow.app/ahg/kit/raw/.github/skills/keyboard-navigator/references/tab-order.md - Everything in the kit
Copy it into ChatGPT or another assistant
Read the plain text first
Keyboard Navigator reference: Tab Order
Part of the keyboard-navigator skill. Read this only when the task reaches these sections.
Tab Order
Natural Order
- DOM order determines tab order
- Never use
tabindexvalues greater than 0. They break natural flow and create unpredictable navigation tabindex="0"makes non-interactive elements focusable (use sparingly)tabindex="-1"makes elements programmatically focusable but not in tab order (used for focus management)
Verification
When auditing, trace the tab order through the entire page:
- Start at the skip link
- Tab through every interactive element
- Verify order matches visual layout (left to right, top to bottom)
- Verify no elements are skipped
- Verify no unexpected elements receive focus
Grep for problems:
tabindex="[1-9] # Positive tabindex -- almost always wrong
outline: none # Focus indicator possibly removed
outline: 0 # Focus indicator possibly removed
Focus Management
Page/Route Changes (SPA)
When the route changes in a single-page app:
- Focus must move to the new page content
- Recommended: focus the H1 or main content area
- The H1 or main should have
tabindex="-1"so it can receive programmatic focus - Screen reader must announce the new page (the heading text)
- Never leave focus on the navigation link that was just clicked
// After route change
const heading = document.querySelector('h1');
heading.setAttribute('tabindex', '-1');
heading.focus();Dynamic Content
When content appears dynamically (search results, loaded sections, notifications):
- If the user triggered it: move focus to the new content or announce via live region
- If it appeared automatically: use
aria-liveto announce, do not steal focus - Toast notifications:
aria-live="polite", never move focus to them
Deletion and Removal
When an item is deleted from a list:
- Focus moves to the next item in the list
- If last item was deleted, focus moves to the previous item
- If list is now empty, focus moves to a relevant element (the list container or a heading)
- Never let focus disappear into the void