Repository navigation
fix(SegmentedControl): a disabled control, or a disabled selected segment, keeps the Tab stop - #9314
Conversation
…ment, keeps the Tab stop spec:AST-085 FR1 through SegmentedControl FR2 and FR7, which recorded these as implementation gaps: - A control disabled without a disabledMessage had no Tab stop and ignored the pointer. It now keeps one Tab stop on the selected segment, with pointer events on; selection stays blocked. - A selected segment disabled on its own lost the stop to the first enabled segment, and once the stop had fallen back there, selecting another segment left it behind. The selected segment now always holds the stop. The control places its stop through useListFocus's internal tabStopOrder (renamed from disabledTabStop), which now applies after every commit and keyboard move, not only while every segment is disabled. The records drop the three gaps; the a11y state facts for the disabled group and its selected segment now expect a Tab stop.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
There was a problem hiding this comment.
The Tab-stop fix works: a disabled SegmentedControl, and a selected segment that is itself disabled, now keep the selected segment as the control's one Tab stop, and the new tests fail on main and pass here. Two things need fixing before this can merge:
- From a disabled selected segment that sits between enabled ones, the arrow keys go the wrong way (with Grid | List (disabled, selected) | Table, ArrowRight selects Grid), because
handleKeyDowninuseListFocus.tsrestarts from the ends of the list when the focused segment is not among the enabled items. - The
segmented-option-group-disabledrow inRadioGroup.a11y.states.tsstill declarestabReachable: false(theoptionFactsdefault), so the release-only Chromium spec will flag the new Tab stop, and the verification rows in both SegmentedControl records still describe the removed gaps. - While there, the
bestPracticesline inSegmentedControl.doc.mjsstill says disabled controls swallow hover events, which is no longer true.
[Automated review]
| expect(onChange).not.toHaveBeenCalled(); | ||
| // Arrows still move to enabled segments and select them. | ||
| await user.keyboard('{ArrowRight}'); | ||
| expect(onChange).toHaveBeenCalledTimes(1); |
There was a problem hiding this comment.
With Grid | List (disabled, selected) | Table, this ArrowRight selects grid, the segment to the left of List: getCurrentIndex() is -1 because items excludes the focused disabled segment, so handleKeyDown restarts at index 0. Asserting expect(onChange).toHaveBeenCalledWith('table') here (and 'grid' for ArrowLeft) would catch it.
| // An owner-placed stop may sit on an element outside `items`, such as | ||
| // a disabled checked radio; it gives way to the target too. |
There was a problem hiding this comment.
Arrow movement needs the same awareness: when focus sits on this owner-placed stop, getCurrentIndex() returns -1 and handleKeyDown (lines 768-782) starts from the first or last enabled item instead of the neighbour in the pressed direction. Starting from the focused element's document position (the first enabled item after it for next, the last before it for previous) fixes it here for every caller.
| binding: 'SegmentedControlItem', | ||
| summary: | ||
| 'a selected segment disabled by its group and removed from Tab order', | ||
| summary: 'a selected segment disabled by its group that keeps the Tab stop', |
There was a problem hiding this comment.
optionFacts defaults tabReachable to false (line 93), so with the override removed this row still declares the segment unreachable, the opposite of its new summary. The release-only RadioGroup.a11y.chromium.spec.ts will report declares tabReachable=false, page exposes true. Add tabReachable: true, as the -with-message row has.
| { | ||
| guidance: false, | ||
| description: | ||
| 'Wrap a disabled SegmentedControl in Tooltip to explain why it is disabled; disabled controls swallow the hover events the wrapper needs. Use the disabledMessage prop instead.', |
There was a problem hiding this comment.
A disabled control keeps its pointer events after this change, so this reason no longer holds. Reword it like the disabledMessage description ("so the reason is attached to the control itself"). The same text is at lines 316 and 352.
PR Analysis Report🔎 Preview ·
|
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| RadioListItem | 55.6 kB (0) · 10.0 kB CSS (0) | — | ✓ · ✓ · ✗ |
| SegmentedControlItem | 9.7 kB (−21 B) · 4.0 kB CSS (0) | — | ✓ · ✓ · ✗ |
| lab/CommentPin | 50.6 kB (+144 B) · 1.2 kB CSS (0) | — | — · — · — |
31 more components
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| SideNavItem | 57.9 kB (+138 B) · 10.4 kB CSS (0) | — | — · — · — |
| Pagination | 89.3 kB (+137 B) · 15.8 kB CSS (0) | — | — · — · — |
| BreadcrumbItem | 70.9 kB (+136 B) · 11.4 kB CSS (0) | — | — · — · — |
| ContextMenu | 78.8 kB (+136 B) · 15.3 kB CSS (0) | — | — · — · — |
| TopNavMenu | 61.2 kB (+128 B) · 10.5 kB CSS (0) | — | — · — · — |
| TableCell | 80.0 kB (+127 B) · 15.7 kB CSS (0) | — | — · — · — |
| TableSelectionToolbar | 55.5 kB (+126 B) · 11.4 kB CSS (0) | — | — · — · — |
| lab/Comments | 226.5 kB (+126 B) · 2.5 kB CSS (0) | — | — · — · — |
| richtext/RichTextEditorToolbar | 217.3 kB (+126 B) · 454 B CSS (0) | — | — · — · — |
| DropdownMenuSubMenu | 62.0 kB (+124 B) · 9.9 kB CSS (0) | — | — · — · — |
| lab/Schedule | 64.0 kB (+124 B) · 3.9 kB CSS (0) | — | — · — · — |
| MoreMenu | 76.9 kB (+120 B) · 15.4 kB CSS (0) | — | — · — · — |
| TableHeaderCell | 79.6 kB (+120 B) · 15.4 kB CSS (0) | — | — · — · — |
| NavHeadingMenu | 13.8 kB (+119 B) · 3.4 kB CSS (0) | — | — · — · — |
| SideNavHeading | 61.7 kB (+119 B) · 10.5 kB CSS (0) | — | — · — · — |
| Table | 88.7 kB (+117 B) · 16.0 kB CSS (0) | — | — · — · — |
| DropdownMenu | 76.6 kB (+116 B) · 15.4 kB CSS (0) | — | — · — · — |
| TabMenu | 58.5 kB (+115 B) · 10.4 kB CSS (0) | — | — · — · — |
| Toolbar | 41.5 kB (+115 B) · 7.9 kB CSS (0) | — | — · — · — |
| Outline | 30.7 kB (+114 B) · 4.2 kB CSS (0) | — | — · — · — |
| TabList | 42.1 kB (+114 B) · 7.4 kB CSS (0) | — | — · — · — |
| TopNavHeading | 61.2 kB (+113 B) · 10.3 kB CSS (0) | — | — · — · — |
| lab/CommentThread | 221.8 kB (+113 B) · 2.4 kB CSS (0) | — | — · — · — |
| ButtonGroup | 9.0 kB (+111 B) · 3.4 kB CSS (0) | — | — · — · — |
| AvatarGroup | 41.8 kB (+109 B) · 6.6 kB CSS (0) | — | — · — · — |
| TopNavMegaMenu | 57.6 kB (+107 B) · 11.1 kB CSS (0) | — | — · — · — |
| lab/MobilePowerSearch | 160.8 kB (+95 B) · 1.2 kB CSS (0) | — | — · — · — |
| Markdown | 149.1 kB (+89 B) · 18.2 kB CSS (0) | — | — · — · — |
| SegmentedControl | 40.8 kB (+85 B) · 6.5 kB CSS (0) | — | ✓ · ✓ · ✓ |
| DateTimeInput | 115.6 kB (+40 B) · 15.6 kB CSS (0) | — | — · — · — |
| RadioList | 47.8 kB (0) · 8.3 kB CSS (0) | — | ✓ · ✓ · ✓ |
Package size: @astryxdesign/core 5.66 MB packed (−58 B); no new dependencies.
API changes: core +8 · ~20 · −0 (report stale: run pnpm api:report); richtext +0 · ~1 · −0 (report stale: run pnpm api:report)
29 API changes (advisory)
| Package | Where | Signature | Usage | |
|---|---|---|---|---|
| + | core |
. · Types · interface FieldStatusProps |
message: string |
import type {FieldStatusProps} from '@astryxdesign/core'; const x: FieldStatusProps = {message: …} |
| + | core |
. · Types · interface FieldStatusProps |
ref?: React.Ref<HTMLDivElement> |
import type {FieldStatusProps} from '@astryxdesign/core'; const x: FieldStatusProps = {ref: …} |
| + | core |
. · Types · interface FieldStatusProps |
type: InputStatusType |
import type {FieldStatusProps} from '@astryxdesign/core'; const x: FieldStatusProps = {type: …} |
| + | core |
. · Types · interface FieldStatusProps |
variant?: FieldStatusVariant = 'attached' |
import type {FieldStatusProps} from '@astryxdesign/core'; const x: FieldStatusProps = {variant: …} |
| + | core |
. · Types · interface FieldStatusProps |
xstyle?: StyleXStyles |
import type {FieldStatusProps} from '@astryxdesign/core'; const x: FieldStatusProps = {xstyle: …} |
| + | core |
. · Types · interface FieldStatusProps |
inherits AriaAttributes, DOMAttributes, HTMLAttributes |
import type {FieldStatusProps} from '@astryxdesign/core' |
| + | core |
. · Types · interface SearchContext |
interface SearchContext<T extends SearchableItem = SearchableItem> |
import type {SearchContext} from '@astryxdesign/core' |
| + | core |
./Typeahead · Also exported from an earlier entry point · SearchContext |
SearchContext (.) |
import {SearchContext} from '@astryxdesign/core/Typeahead' |
| ~ | core |
. · Components · component ComplexSelector |
prop statusVariant?: FieldStatusVariant = 'attached' for input selectors; 'detached' for secondary and ghost selectors → prop statusVariant?: FieldStatusPlacement = 'attached' for input selectors; 'detached' for secondary and ghost selectors |
<ComplexSelector statusVariant="attached" /> |
| ~ | core |
. · Components · component DateInput |
prop statusVariant?: FieldStatusVariant = 'attached' → prop statusVariant?: FieldStatusPlacement = 'attached' |
<DateInput statusVariant="attached" /> |
| ~ | core |
. · Components · component DateRangeInput |
prop statusVariant?: FieldStatusVariant = 'attached' → prop statusVariant?: FieldStatusPlacement = 'attached' |
<DateRangeInput statusVariant="attached" /> |
| ~ | core |
. · Components · component Field |
prop statusVariant?: FieldStatusVariant = 'attached' → prop statusVariant?: FieldStatusPlacement = 'attached' |
<Field statusVariant="attached" /> |
| ~ | core |
. · Components · component FieldStatus |
component FieldStatus(props: FieldStatusProps) → component FieldStatus @deprecated |
<FieldStatus /> |
| ~ | core |
. · Components · component FieldStatus |
prop variant?: FieldStatusVariant = 'attached' → prop variant: FieldStatusVariant = 'attached' |
<FieldStatus variant="attached" /> |
| ~ | core |
. · Components · component FileInput |
prop statusVariant?: FieldStatusVariant = 'attached' → prop statusVariant?: FieldStatusPlacement = 'attached' |
<FileInput statusVariant="attached" /> |
| ~ | core |
. · Components · component MultiSelector |
prop statusVariant?: FieldStatusVariant = 'attached' for input selectors; 'detached' for secondary and ghost selectors → prop statusVariant?: FieldStatusPlacement = 'attached' for input selectors; 'detached' for secondary and ghost selectors |
<MultiSelector statusVariant="attached" /> |
| ~ | core |
. · Components · component NumberInput |
prop statusVariant?: FieldStatusVariant = 'attached' → prop statusVariant?: FieldStatusPlacement = 'attached' |
<NumberInput statusVariant="attached" /> |
| ~ | core |
. · Components · component PowerSearch |
prop statusVariant?: FieldStatusVariant = 'attached' → prop statusVariant?: FieldStatusPlacement = 'attached' |
<PowerSearch statusVariant="attached" /> |
| ~ | core |
. · Components · component Selector |
prop statusVariant?: FieldStatusVariant = 'attached' for input selectors; 'detached' for secondary/ghost selectors → prop statusVariant?: FieldStatusPlacement = 'attached' for input selectors; 'detached' for secondary/ghost selectors |
<Selector statusVariant="attached" /> |
| ~ | core |
. · Components · component TextArea |
prop statusVariant?: FieldStatusVariant = 'attached' → prop statusVariant?: FieldStatusPlacement = 'attached' |
<TextArea statusVariant="attached" /> |
| ~ | core |
. · Components · component TextInput |
prop statusVariant?: FieldStatusVariant = 'attached' → prop statusVariant?: FieldStatusPlacement = 'attached' |
<TextInput statusVariant="attached" /> |
| ~ | core |
. · Components · component TimeInput |
prop statusVariant?: FieldStatusVariant = 'attached' → prop statusVariant?: FieldStatusPlacement = 'attached' |
<TimeInput statusVariant="attached" /> |
| ~ | core |
. · Components · component Tokenizer |
prop statusVariant?: FieldStatusVariant = 'attached' → prop statusVariant?: FieldStatusPlacement = 'attached' |
<Tokenizer statusVariant="attached" /> |
| ~ | core |
. · Components · component Typeahead |
prop statusVariant?: FieldStatusVariant = 'attached' → prop statusVariant?: FieldStatusPlacement = 'attached' |
<Typeahead statusVariant="attached" /> |
| ~ | core |
. · Types · interface FieldStatusProps |
interface FieldStatusProps extends BaseProps<HTMLDivElement> (props of FieldStatus) → interface FieldStatusProps extends BaseProps<HTMLDivElement> |
import type {FieldStatusProps} from '@astryxdesign/core' |
| ~ | core |
. · Types · interface FieldStatusVariantMap |
tooltip: true → tooltip: true @deprecated |
import type {FieldStatusVariantMap} from '@astryxdesign/core'; const x: FieldStatusVariantMap = {tooltip: …} |
| ~ | core |
. · Types · interface SearchSource |
search: (query: string) => Promise<T[]> | T[] → search: (query: string, context?: SearchContext<T>) => Promise<T[]> | T[] |
import type {SearchSource} from '@astryxdesign/core'; const x: SearchSource = {search: …} |
| ~ | core |
. · Types · interface UseInputStatusIconOptions |
statusVariant?: FieldStatusVariant → statusVariant?: FieldStatusPlacement |
import type {UseInputStatusIconOptions} from '@astryxdesign/core'; const x: UseInputStatusIconOptions = {statusVariant: …} |
| ~ | richtext |
. · Components · component RichTextEditor |
prop statusVariant?: FieldStatusVariant = 'attached' → prop statusVariant?: FieldStatusVariant | 'tooltip' = 'attached' |
<RichTextEditor statusVariant="tooltip" /> |
Touched components checked; add ci:run-visual or ci:run-rtl to run the full suites.
Accessibility: 2 violation(s)
Accessibility Audit
Status: 2 accessibility violation(s) found — 2 serious.
Radio group pattern - 1 issue(s)
- 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
- Rule:
color-contrast· Affects 3/21 stories · Learn more - WCAG: 1.4.3 (Level AA)
- Rule:
RadioList - 1 issue(s)
- 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
- Rule:
color-contrast· Affects 3/14 stories · Learn more - WCAG: 1.4.3 (Level AA)
- Rule:
Generated by PR Enrichment workflow | View full report
…o its neighbour; records match the a11y states CodeBunny on #9314: - From focus on a disabled selected segment, which is not one of the list's navigable items, arrows started from the ends, so ArrowRight on a middle segment could select the one to its left. With an owner-placed stop, useListFocus now starts from the stop's place in document order. - The verification rows still said the disabled-group a11y states declare no Tab stop; they now say the states declare one. - The two .doc.mjs edits keep the files' existing formatting.
There was a problem hiding this comment.
The Tab-stop fix works: a disabled SegmentedControl, and a selected segment that is itself disabled, now keep the selected segment as the control's one Tab stop, and arrows from that segment now move the right way. Two things need fixing before this can merge:
- The
segmented-option-group-disabledrow inRadioGroup.a11y.states.tsstill inheritstabReachable: falsefromoptionFacts, so it contradicts its new summary and theSegmentedControlItem.spec.mdverification row;RadioGroup.a11y.chromium.spec.tsis release-only, so it will not run on this PR and will first fail onmain. AddingtabReachable: truefixes both. - The three
bestPracticesentries inSegmentedControl.doc.mjsstill say disabled controls swallow hover events, which this change makes untrue; reword them like thedisabledMessagedescription.
[Automated review]
| summary: 'a selected segment disabled by its group that keeps the Tab stop', | ||
| facts: optionFacts({ | ||
| checked: true, | ||
| disabled: true, | ||
| operable: false, | ||
| tabReachable: false, | ||
| pointerCancellation: false, |
There was a problem hiding this comment.
optionFacts defaults tabReachable to false (line 93), so this row still declares the segment unreachable: the opposite of its summary, and of what Tab does on this head (it lands on List). RadioGroup.a11y.chromium.spec.ts is @pr-a11y release-only, so ci:run-a11y does not run it here and it will first fail on main's release check. Add tabReachable: true, as the segmented-option-group-disabled-with-message row does.
| | FR1 | `SegmentedControl.test.tsx` aria-checked and data-testid cases; `RadioGroup.a11y.test.tsx` and `RadioGroup.a11y.chromium.spec.ts` (in `RadioList/__tests__`) `segmented-option-*` states | Selection change; data-testid | Stale `aria-checked` fails. Evidence gap: no test passes `role` to a segment; the role-override case covers the radiogroup. | `audit:SegmentedControlItem/accessibility` | | ||
| | FR2 | `SegmentedControl.test.tsx` click and onClick-composition cases | Click; selected click; prevented click | A selected or prevented click that selects fails. Evidence gap: no test covers a press while focus is already in the group. | `audit:SegmentedControlItem/behavior` | | ||
| | FR3 | `SegmentedControl.test.tsx` icon, icon-only, and truncation cases | Icon and label; icon-only; long label | A missing name, or an icon that truncates, fails. | `audit:SegmentedControlItem/anatomy` | | ||
| | FR4 | `SegmentedControl.test.tsx` disabled cases; `RadioGroup.a11y.test.tsx` and `RadioGroup.a11y.chromium.spec.ts` (in `RadioList/__tests__`) `segmented-option-disabled` and `segmented-option-group-disabled*` states | Item and group disabled | A disabled segment that selects fails. Evidence gap: no test asserts the disabled text color, absent hover paint, or the caller `onClick` while disabled. The `segmented-option-group-disabled` state declares a checked, group-disabled segment that keeps the Tab stop. | `audit:SegmentedControlItem/accessibility` | |
There was a problem hiding this comment.
Not true at this head yet: the segmented-option-group-disabled state still inherits tabReachable: false from optionFacts in RadioGroup.a11y.states.ts. It becomes true once that row sets tabReachable: true.
… Tab stop CodeBunny on #9314: optionFacts defaults tabReachable to false, so dropping the override left the state declaring no Tab stop; it now says true.
There was a problem hiding this comment.
The Tab-stop fix and the corrected segmented-option-group-disabled row work: a disabled SegmentedControl, and a disabled selected segment, now keep the selected segment as the one Tab stop, and the row matches what Tab does. One thing still needs fixing before merge: the three bestPractices entries in SegmentedControl.doc.mjs (lines 233, 249 and 265) still say disabled controls swallow hover events, which this change makes untrue, so reword them like the disabledMessage description (the DisabledWithMessage story comment repeats the same reason).
[Automated review]
…bled controls swallow hover CodeBunny on #9314: a disabled control now keeps pointer events, so the reason to use disabledMessage is that it attaches the reason to the control.
There was a problem hiding this comment.
This is ready to approve: a disabled SegmentedControl, and a disabled selected segment, now keep the selected segment as the one Tab stop, the stop follows later selections, and the Tooltip best-practice no longer says disabled controls swallow hover. One optional wording fix: a Tooltip wrapper does put its reason on the radiogroup's aria-describedby, so "not attached to the control" in that best-practice is only half true; "the reason then describes only the group, not the focused segment, and does not open on keyboard focus" would be exact. The spec-owner-approval check is still waiting for an engineering owner to approve the record edits.
[Automated review]
| {guidance: false, description: 'Use for page-level navigation; use TabList instead. TabList is a navigation component, while SegmentedControl is an input that always has exactly one selected option.'}, | ||
| {guidance: false, description: 'Use for simple on/off states; use ToggleButton instead. ToggleButton can be toggled on or off independently, while SegmentedControl enforces a single selection from a group.'}, | ||
| {guidance: false, description: 'Wrap a disabled SegmentedControl in Tooltip to explain why it is disabled; disabled controls swallow the hover events the wrapper needs. Use the disabledMessage prop instead.'}, | ||
| {guidance: false, description: 'Wrap a disabled SegmentedControl in Tooltip to explain why it is disabled; the reason is then not attached to the control or its segments. Use the disabledMessage prop instead.'}, |
There was a problem hiding this comment.
Optional wording: a Tooltip wrapper does put its reason on the radiogroup's aria-describedby; what it misses is the focused segment and keyboard focus (the radiogroup itself is not focusable, so the tooltip does not open on focus). Suggest: "...; the reason then describes only the group, not the focused segment, and does not open on keyboard focus." Same text at lines 249 and 265.
|
/approve-spec 513f8de |
Conflicts: RadioListItem keeps aria-disabled, the form detach and the disabled radio's dropped required, and takes main's reason context and status-following aria-invalid; RadioList nests the form and reason contexts. Records keep this branch's FR4/FR5 rows, take main's FR6 aria-invalid clause and RTL verification row, and drop the group-reason gap #9169 closed.
User impact
Keyboard and screen-reader users could miss a SegmentedControl, or land on the wrong segment.
disabledMessagehad no Tab stop, so Tab skipped it and a screen-reader user moving by focus never heard that the choice existed or that it was locked.Now the selected segment always holds the control's one Tab stop. It is announced as disabled (
aria-disabled) when it is, and nothing can be selected while disabled. Arrow keys still move to enabled segments and select them.Problem and solution fit
useListFocus) only ever placed the stop on an enabled segment, and on a fully disabled control only when it had a reason. The control's owntabIndexthen dropped disabled segments, and the disabled style also turned pointer events off.useListFocus's internaltabStopOrderoption (renamed fromdisabledTabStop, which only SegmentedControl used). The option now applies after every commit and keyboard move, not only while every segment is disabled. The order is the selected segment, enabled or not; otherwise the first segment not disabled on its own; otherwise the first. A disabled control keeps pointer events, so a press focuses the stop and a reason tooltip can open; the existing guards still block selection.useListFocusnow starts from the stop's place in document order.Current specification
spec:AST-085FR1: a disabled control keeps its Tab stop.component:SegmentedControlFR2 ("a disabled selected segment MUST keep the Tab stop") and FR7 ("The group MUST keep a Tab stop while disabled") already required this and recorded the behavior as implementation gaps. So didcomponent:SegmentedControlItemFR4.This PR removes those three gaps from both records, including their Current-state impact bullets and summary rows, and states ORD2 and the "Disabled, no reason" state as they now hold. FR7 now says the stop is "placed as in FR2" with pointer events on. The remaining gap, caller handlers running while disabled (FR7), is untouched.
The two summary tables and FR tables re-align because their widest rows got shorter; the wording changes are only the ones listed.
Writing rubric results
Evidence
main, green here (SegmentedControl.test.tsx, "Tab stop (spec:AST-085 FR1)"):useListFocus.test.tsx:tabStopOrderplaces the stop on a disabled item while other items are enabled (red onmain).RadioGroup.a11y.states.ts: the disabled group and its selected segment now declare a Tab stop.RadioGroup.a11y.chromium.spec.tschecks every declared fact against real Tab traversal. It is a release-check contract that the PR job does not run, so I ran it in Google Chrome 156 against Storybook built from e1c05e4 (the later commit changes only.doc.mjstext): 28 passed, every segmented state included. Againstmain's Storybook (372a0ea) the same facts fail exactly where expected: "segmented-group-disabled: declares tabReachable=true, page exposes false", and the same for segmented-option-group-disabled.ci:run-a11y) ran and passed.tscfor core: clean.pnpm check:knowledge: aligned.LOC
+255 / −154. About 75 product lines and about 115 test lines; most of the rest is the records' tables re-aligning.
Scope
component:SegmentedControlandcomponent:SegmentedControlItem.