refactor(tablist): use useListFocus hasRovingTabIndex instead of inline repair#3484
Draft
cixzhang wants to merge 1 commit into
Draft
refactor(tablist): use useListFocus hasRovingTabIndex instead of inline repair#3484cixzhang wants to merge 1 commit into
cixzhang wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
josephfarina
approved these changes
Jul 3, 2026
Contributor
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR No new or modified components detected. Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Refactors
TabListto fully useuseListFocus's built-in roving-tabindex support (hasRovingTabIndex) instead of a hand-rolled tab-stop repair effect.useListFocusnow owns the single tab stop across the tab strip: it stampstabindex0/-1, repairs the stop on mount and as stops mount/unmount or toggle disabled, and — viahandleFocuson the<nav>— keeps the stop in sync after clicks or programmatic focus. This natively replaces the inlineuseIsomorphicLayoutEffectinTabList.tsxthat queried nav stops, checked whether any hadtabIndex === 0, and promoted the first enabled one if not.Changes
hasRovingTabIndex: trueto the existinguseListFocuscall.handleFocusfrom the hook and wire it asonFocuson the<nav>(keeps the roving stop in sync with whatever got focus).useIsomorphicLayoutEffecttab-stop repair block, its now-unusedisDisabledStophelper, and theuseIsomorphicLayoutEffectimport.Tab.tsxis unchanged: it keeps renderingtabIndex={isSelected ? 0 : -1}as the initial source of truth. The hook'ssyncTabStops(enabled.find(el => tabindex === '0') ?? enabled[0]) preserves an existing tab stop and only promotes the first enabled stop when none is tabbable — matching the deleted effect's behavior exactly, so the selected tab remains the initial tab stop.Behavior
No behavior change. Arrow / Home / End navigation, wrapping, and disabled-skip were already handled by
useListFocus; the initial-tab-stop and repair semantics are now handled natively by the hook rather than duplicated inline.Verification
pnpm -F @astryxdesign/core typecheck— exit 0eslint TabList.tsx Tab.tsx— cleanvitest run packages/core/src/TabList— 31/31 pass (no keyboard regression)vitest run packages/core/src/hooks/useListFocus— 23/23 pass