fix: avoid redundant radiogroup tab stop - #343
Conversation
|
@nrps9909 is attempting to deploy a commit to the afc163's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (2)
💤 Files with no reviewable changes (1)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. Walkthrough
ChangesSegmented 键盘焦点行为
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This localized accessibility behavior change removes the redundant default group tab stop while preserving explicit overrides, with focused test and snapshot updates; no actionable merge-blocking risk remains after normal checks and review. Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Full details: Docstring CoverageExplanation No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1 files. ✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
tabIndex=0from the outer radiogrouptabIndexoverrideWhy
Segmented already renders native radio inputs and handles Arrow keys on those inputs. The outer
radiogroupwas also focusable by default, so keyboard users had to Tab twice: first onto a group node where Arrow keys do nothing, then onto the checked radio where the interaction actually works.This aligns the focus path with the WAI-ARIA radio-group pattern: Tab enters the group on a checked radio (or the first radio when none is checked), and Arrow keys move within the group.
The exact-base regression fails because the first Tab focuses
radiogroup[tabindex="0"]instead of the checked native radio.Reference: https://www.w3.org/WAI/ARIA/apg/patterns/radio/
Compatibility
SegmentedPropsstill accepts the inherited HTMLtabIndexprop. Because the remaining...divPropsspread applies it to the outer group, consumers that intentionally need a focusable group can continue to opt in; the added test covers that path.Validation
npm test -- --runInBand(33 tests, 13 snapshots)npm run tscnpm run lint(no errors; one pre-existingMotionThumb.tsxexhaustive-deps warning)npx prettier --check src/index.tsx tests/index.test.tsxnpm run compilegit diff --checkOverlap audit
No currently open rc-segmented PR changes
src/index.tsxor its keyboard tests.AI assistance disclosure: Codex was used to trace the focus path, audit open PR files and history, and draft the regression. The exact-base failure and fixed validation were run locally.
Summary by CodeRabbit
tabindex,避免产生额外的焦点停留。tabindex="0"。