Skip to content

test(a11y): Slider contract and binding - #7483

Merged
cixzhang merged 10 commits into
mainfrom
a11y-slider-contract
Oct 13, 2026
Merged

cixzhang merged 10 commits into
mainfrom
a11y-slider-contract

Conversation

@cixzhang

@cixzhang cixzhang commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

What this proves

component:Slider AR1 (the Slider adoption recorded in #7463 under spec:AST-020 FR15) now has an executable contract and a binding. A keyboard or screen-reader user on a Slider thumb gets: a named slider that states its value and bounds (and a formatted value when one is set), says when it is vertical, steps with the arrows — the horizontal arrows following the track's direction on a right-to-left page — pages with Page Up/Down, jumps to the bounds with Home/End, and, when disabled but still focusable for its message, never changes under the keyboard.

Test-only: no runtime, docs, or Changeset. Enforcement follows spec:AST-020 FR9: component:Slider AR1 is current on main (#7463) and adopts ten-step Page keys, so every expectation — Page Up/Down included — is required.

Expectations (AST-020 FR13)

Expectation Sources Layer Enforcement
slider.thumb.role-and-name WCAG 4.1.2, APG Slider, APG Slider accessibility-tree required
slider.thumb.value-properties WCAG 4.1.2, APG Slider dom required
slider.thumb.value-text WCAG 4.1.2, APG Slider dom required
slider.thumb.orientation WCAG 4.1.2, APG Slider dom required
slider.keys.arrows-step WCAG 2.1.1, APG Slider, APG Slider, component:Slider AR1 real-browser required
slider.keys.page WCAG 2.1.1, APG Slider, component:Slider AR1 real-browser required
slider.keys.home-end WCAG 2.1.1, APG Slider, component:Slider AR1 real-browser required
slider.thumb.unavailable-keeps-value WCAG 4.1.2, APG Slider real-browser required

Exemptions: 1.1.1-non-text-content → the binding component; 1.3.1-info-and-relationships → the binding component and caller content; 1.3.2-meaningful-sequence → the binding component and composing page; 1.3.5-identify-input-purpose → not applicable; 1.4.1-use-of-color → the binding component and theme; 1.4.3-contrast-minimum → the binding component and theme; 1.4.11-non-text-contrast → the binding component and theme; 2.1.1-keyboard → the composing page (remainder only); 2.1.2-no-keyboard-trap → the binding component and composing page; 2.4.2-page-titled → the page; 2.4.3-focus-order → the composing page; 2.4.4-link-purpose → not applicable; 2.4.6-headings-and-labels → the binding component and caller content (remainder only); 2.4.7-focus-visible → the binding component and theme; 2.4.11-focus-not-obscured → the composing page; 2.5.2-pointer-cancellation → the binding component; 2.5.3-label-in-name → the binding component; 2.5.8-target-size → the binding component and theme; 3.1.1-language-of-page → the page; 3.2.2-on-input → the caller and composing page; 3.2.4-consistent-identification → the composing page; 3.3.1-error-identification → the binding component; 3.3.2-labels-or-instructions → the binding component and caller content; 4.1.2-name-role-value → the binding component (remainder only); 4.1.3-status-messages → the caller and the assistive-technology verification record, spec:AST-009; apg-interaction → the binding component's record (remainder only); forced-colors → the binding component and theme; reduced-motion → the binding component and theme; at-facing-strings → the binding component and caller content

Known failures (exact records, reconciled in both lanes)

Binding / state Expectation Exact failure User impact Authority / fix
Slider / step-three slider.keys.home-end End left aria-valuenow at 99, not 100 With a step that does not divide the range, End stops one step short of the maximum while ArrowRight and PageUp reach it. component:Slider AR1 names this gap (End moves to max); its own endpoint fix follows.

Shape

  • internal/a11y-spec/src/patterns/slider.ts — SLIDER_PATTERN, 8 expectations, all required now that AR1 is current with WCAG and APG sources (APG Slider wording verified against the published pattern on 2026-10-13); every other checklist dimension exempted to a named owner.
  • slider.fixtures.ts — an HTML thumb whose <script> implements the keyboard model (Chromium runs it; the DOM lane only reads attributes); every expectation has at least one violating twin (SLIDER_MUTATIONS).
  • slider.jsdom.test.ts (33 cases) and slider.chromium.spec.ts.
  • internal/a11y-spec/src/harness.ts + harness/chromium.ts — Key gains Home, End, PageUp, PageDown (additive).
  • packages/core/src/Slider/__tests__/Slider.a11y.{states,renders,known-failures,test}.tsx and Slider.a11y.chromium.spec.ts — six states: horizontal, vertical, horizontal RTL, formatted value, disabled with message (focusable, inoperable), step 3.
  • apps/storybook/stories/SliderA11y.stories.tsx — one no-visual story per state, rendered through renderSliderState so the lanes cannot drift.
  • .github/workflows/ci.yml — "Run Slider accessibility contract" step; runs when Slider, the harness, the stories, or the contract change.
  • README row and index export; workflow step and README row rebased after the merged Accordion contract; the step scopes through pr-scope-touches.sh from the base.

Source lines behind the binding facts

role="slider", tabIndex (focusable when disabled with a message), aria-valuemin/max/now/valuetext/orientation/disabled, aria-labelledby (Slider.tsx L936–955); keys: ArrowRight/Up +step, ArrowLeft/Down −step, Page ±10 steps, Home/End to min/max, then snap-then-clamp for arrows and Page keys (L828–857, snapToStep L396–401 — the source of the step-3 End gap until #7484); the RTL swap of the horizontal arrows is on main (#7461).

Ownership exclusions

SLIDER_EXCLUSIONS: range-thumb separation and group semantics (binding's own tests); pointer drag model, track clicks and the value tooltip.

Evidence

  • Vitest Slider directory: 93/93 (incl. 10 binding cases); pattern jsdom self-test 34/34 (a violating-no-valuemin fixture joins the map; value-properties now reads every bound the way it reads aria-valuenow, so an absent aria-valuemin fails even at min 0); tsc (core, a11y-spec, storybook), eslint, Prettier, visual-workflow-owner clean.
  • Real Chromium: the CI step on this PR runs the fixture self-test (conforming pass, every mutation fails) and the six binding states, reconciling the one remaining known failure (step-three End) exactly; the RTL row passes now that fix(Slider): horizontal arrow keys follow the mirrored track under RTL #7461 is on main.

SLIDER_PATTERN encodes the APG Slider parts component:Slider AR1 adopts per
thumb: role and name, now/min/max, value text, orientation, arrow steps
(inline arrows following the track under RTL), Page keys (advisory,
APG-optional), Home/End to the bounds, and an unavailable thumb keeping its
value. Fixtures carry a small script implementing the model so the Chromium
self-test proves every mutation; the harness gains Home/End/PageUp/PageDown.
The Slider binding has six states; two exact known failures record the
shipped gaps the record names (RTL arrows not mirrored; End one step short
when the step does not divide the range), each fixed by its own patch.
Stories through the shared renderer, a CI step, and the README row.
Test-only.
@vercel

vercel Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Oct 13, 2026 9:54pm UTC

Request Review

@astracat-bot

astracat-bot Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Oct 13, 2026, 10:29 PM UTC

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 13, 2026
@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR

🧪 Sandbox Preview

View Sandbox for this PR

Modified Components

Slider (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 944 -
Complexity N/A Very High (145) -

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.9KB 1.2KB

Accessibility Audit

Status: No accessibility violations detected.

Visual Regression

44 of 448 shot(s) changed.

A change here is a question, not a failure: check whether the after is the
picture you intended. Record that review on the PR. Baseline maintenance is an
explicit dispatch of CI; this report never rewrites the baseline or adds a release gate.

component story theme mode pixels
Selector Indicator Space Bottom Sheet Narrow End RTL neutral light 754,077
Selector Indicator Space Bottom Sheet Wide Start neutral light 740,188
Chat Full AI Chat probe light 238,081
Chat Full AI Chat probe dark 237,048
Markdown Default probe light 159,625
Markdown Default probe dark 158,986
Collapsible Dividers probe dark 66,445
Collapsible Dividers probe light 66,445
Chat Default neutral dark 33,205
Chat Default neutral light 32,876
Chat Empty State probe light 23,531
Chat Empty State probe dark 22,622
ChatAutoScroll Scroll Behavior Comparison neutral dark 15,378
ChatAutoScroll Scroll Behavior Comparison neutral light 14,107
Chat With Attachments probe light 13,406
Chat With Attachments probe dark 11,232
ProgressBar With Target Mark probe dark 7,895
ProgressBar With Target Mark probe light 7,895
TableRowExpansion Detail Panel neutral dark 5,150
TableRowExpansion Detail Panel neutral light 4,068

and 24 more.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

… by 30 for the step-3 fixture; binding spec titles name Slider

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This review is on hold for a maintainer decision: the new contract enforces Slider's arrow and Home/End keys, the right-to-left arrow direction, and End reaching max as required, but no current Slider record adopts those behaviors yet. Approval needs a maintainer to land the component:Slider AR1/DEC-2 record (#7463) with those claims as written, or to keep those expectations advisory under AST-020 FR9 until it does. Separately, please switch the new “Run Slider accessibility contract” CI step to the base-loaded pr-scope-touches.sh helper the other contract steps use: its two-dot git diff "$BASE_SHA" HEAD will list these new files on every component branch cut before this merges, so pr-a11y would fail there with “No tests found”.

[Automated review]

Comment thread .github/workflows/ci.yml Outdated
Comment on lines +1597 to +1604
if git fetch --quiet --depth=1 origin "$BASE_SHA"; then
if git diff --name-only "$BASE_SHA" HEAD \
| grep -qE '^(internal/a11y-spec/src/patterns/slider|internal/a11y-spec/src/harness|packages/core/src/Slider/|apps/storybook/stories/SliderA11y)'; then
should_run=true
fi
else
should_run=true
fi

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This two-dot diff is what pr-scope-touches.sh replaced in the other contract steps. pr-a11y checks out the PR head, so once this merges, a component branch cut earlier sees the Slider contract files as changed, sets should_run=true, and Playwright exits 1 with “No tests found” because those specs are not in that checkout. Loading the helper from the base, exactly as the Landmark and Link steps do (same pattern), avoids it.

Comment on lines +182 to +184
// Every consumer loads the helper from the base; new contract steps add
// consumers, so the count is a floor, not an exact tally.
expect(uses.length).toBeGreaterThanOrEqual(4);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At this head the Slider step does not load the helper, so the workflow still has exactly four consumers, as on main. The floor becomes meaningful once the Slider step uses the helper (or the exact count can move to 5).

},
evidenceLayer: 'real-browser',
alsoNeeds: ['dom'],
enforcement: 'required',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

required here (and on slider.keys.home-end) comes from listing WCAG 2.1.1 first, but the recorded RTL and step-3 failures leave the slider keyboard-operable, so what fails is the APG/AR1 mechanic. Under AST-020 FR9 that needs a current adopting record, and component:Slider on main does not adopt keyboard behavior yet; this waits on the AR1/DEC-2 record landing as written, or ships advisory until then.

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested: now that component:Slider AR1 is current and adopts Page Up/Page Down (ten steps), slider.keys.page should be required rather than advisory under AST-020 FR9 — its own advisoryBecause says as much, and as written a Page regression in Slider would only be reported. Slider already passes that row in every operable state, so the flip needs no new known-failure record; please also update the expectation table in the description and rebase onto main, where the CI workflow and the a11y-spec README now conflict with the Accordion contract. With the Slider record landed and the CI step scoped from the base, the rest of the contract is in good shape.

[Automated review]

},
evidenceLayer: 'real-browser',
alsoNeeds: ['dom'],
enforcement: 'advisory',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

component:Slider AR1 is now current and adopts Page keys (“PageUp and PageDown step by ten steps”), so under AST-020 FR9 this row should be required — the advisoryBecause text below anticipates exactly that. While it stays advisory, blockingResults only reports a Page failure, so a regression in Slider's Page keys would pass pr-a11y. Slider passes this row in all five operable binding states, so flipping it needs no new known-failure record; the description's expectation table should change with it.

id: 'slider.keys.arrows-step',
outcome:
"The inline-forward arrow and Up raise the value by one step, the inline-back arrow and Down lower it, and on a right-to-left track the horizontal arrows follow the track's direction.",
sources: [WCAG_2_1_1, APG_ARROWS, APG_REVERSED],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: the RTL half of this outcome is normative because of component:Slider AR1/DEC-2, not APG_REVERSED, which only says reversing “could create a more intuitive experience”. Citing AR1 as an astryx source with a pinned public URL (as modal-dialog.ts does for component:Dialog) would make the record that gates this row, and the Page and Home/End rows, traceable from the failure output (AST-020 FR4).

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested: the Slider contract and binding match the now-current component:Slider AR1 and CI is green, but slider.thumb.value-properties cannot detect a thumb that loses aria-valuemin whenever its minimum is 0 (every bound state), because Number(null) is 0 and the “absent” guard never fires. Please read aria-valuemin and aria-valuemax the way valueNow reads aria-valuenow, so an absent bound fails, and add a violating-no-valuemin fixture to the mutation map; today, removing the attribute from Slider leaves the new binding green while Slider.test.tsx fails. While there, consider citing AR1 as the source of the RTL, Page and End rows, and refresh the description's evidence and source-line notes, which still mention two known failures and no RTL swap.

[Automated review]

Comment on lines +193 to +198
const min = Number(await subject.attribute('aria-valuemin'));
const max = Number(await subject.attribute('aria-valuemax'));
if (!Number.isFinite(min) || !Number.isFinite(max)) {
throw new Error(
'aria-valuemin or aria-valuemax is absent or not a number',
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Number(null) is 0, so an absent aria-valuemin or aria-valuemax never reaches this guard: a thumb without aria-valuemin passes whenever the state's minimum is 0 (all six Slider states), and an absent maximum is reported as 0 instead of absent. Removing aria-valuemin from Slider leaves the binding green while Slider.test.tsx fails. Reading the bounds the way valueNow reads aria-valuenow closes it:

async function bound(
  subject: Subject,
  name: 'aria-valuemin' | 'aria-valuemax',
): Promise<number> {
  const raw = await subject.attribute(name);
  const parsed = raw == null || raw.trim() === '' ? Number.NaN : Number(raw);
  if (!Number.isFinite(parsed)) {
    throw new Error(`${name} is ${raw ?? 'absent'}, not a number`);
  }
  return parsed;
}

Please also add a violating-no-valuemin fixture (slider({omit: ['aria-valuemin']})) under slider.thumb.value-properties in SLIDER_MUTATIONS (AST-020 FR11).

…emin/aria-valuemax; new violating-no-valuemin fixture; RTL, Page and End rows also cite component:Slider AR1

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is ready for maintainer approval: the Slider contract and binding match the current component:Slider AR1 record, the value-properties row now fails when a thumb drops aria-valuemin or aria-valuemax (removing aria-valuemin from Slider turns all six binding states red), and CI is green on this head. Two optional touch-ups: quote AR1 verbatim in SLIDER_AR1 (it drops the left-to-right clause, and the value-text and reversed-arrow APG quotes drop their "e.g." examples), and refresh the description's Slider.tsx line numbers (thumb ARIA L950–963, keys L830–866). Whichever of this PR and #7484 merges second needs to remove the step-three known-failure entry in that same change.

[Automated review]

clause: 'AR1',
url: 'https://github.com/facebook/astryx/blob/250fd9ac197381ec06900279efc31cbb03544ca9/packages/core/src/Slider/Slider.spec.md#L120-L133',
requirement:
"On a horizontal track the horizontal arrows follow the track's direction — under RTL ArrowLeft increases and ArrowRight decreases; PageUp and PageDown step by ten steps; Home moves to `min` and End to `max`.",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: this isn't a verbatim quote of AR1. The record reads: "on a horizontal track the horizontal arrows follow the track's direction — ArrowRight increases and ArrowLeft decreases under LTR, and under RTL ArrowLeft increases and ArrowRight decreases; PageUp and PageDown step by ten steps; Home moves to min and End to max." AstryxRecord.requirement asks for the requirement "quoted exactly", so paste the full sentence (lower-case "on") or an exact sub-span. APG_VALUETEXT (L54) and APG_REVERSED (L86) similarly drop the published pattern's "e.g." examples.

@cixzhang
cixzhang merged commit c239413 into main Oct 13, 2026
56 checks passed
@github-actions
github-actions Bot deleted the a11y-slider-contract branch October 14, 2026 06:22

This branch was successfully deployed

1 active deployment
Preview — bd877a31 Deployed Oct 13, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant