Skip to content

test(a11y): reusable switch-pattern accessibility contract, bound to Switch - #6115

Merged
cixzhang merged 15 commits into
mainfrom
a11y-switch-contract-20260907
Sep 7, 2026
Merged

cixzhang merged 15 commits into
mainfrom
a11y-switch-contract-20260907

Conversation

@cixzhang

@cixzhang cixzhang commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Switch: the first reusable accessibility spec-test contract

Who this is for

Someone using a screen reader meets a switch and needs three things to be true:
it is announced as a switch and not a checkbox, it says which setting it
controls and whether that setting is on, and it can be turned on and back
off
with the keyboard. Someone using speech input needs the name they can read
to be the name that works. Someone who cannot use a pointer needs Tab to reach
the control and Tab to leave it.

Today each Astryx component proves those things for itself, by reinterpreting
WCAG and the WAI-ARIA APG in its own test file. The interpretations drift, and
most of them are asserted in jsdom, which cannot compute an accessible name,
resolve a tab sequence, or turn a key press into an activation — so several of
those tests were checking that the markup looked plausible.

This adds the shared alternative: the adopted APG pattern written once as a
contract, and Switch bound to it. No component behaviour changes.

Adopted pattern and scope

The WAI-ARIA APG switch pattern,
against the WCAG 2.2 Level A and AA baseline.

The contract owns what is the same for every component that adopts the pattern:
the control is reported as a switch, it is named, its on/off state is exposed
and matches what is rendered, its description reaches the user, pointer and
keyboard both turn it on and back off, focus can reach it and leave it, and a
switch the user is not meant to be able to change says so and stays unchanged.

It does not own anything specific to one component. Callback payloads, form
participation, tooltip composition, and styling stay with the component.

Expectations

Every expectation names one user outcome, the exact clause it comes from, the
one evidence layer that can honestly observe it, and whether it gates. An
expectation only runs against a state it can apply to; otherwise the run reports
not-applicable with the condition, so nothing disappears quietly.
Applicability is normally declared up front, where a reader can see it;
where it can only be discovered from the page — 2.5.3 has nothing to compare
when nothing is rendered visibly — the expectation says so through the runner,
and the result is not-applicable with the reason. It is never a silent early
return, because that would report a pass, and a pass claims the outcome was
observed.

Expectation User outcome Source Applies when Evidence layer Enforcement
switch.role.exposed It is announced as a switch, so the user hears "on" and "off" rather than "checked". WCAG 4.1.2 Name, Role, Value (A) · APG "The switch has role switch." always accessibility tree required
switch.name.exposed It says which setting is being turned on or off. WCAG 4.1.2 (A) · WCAG 3.3.2 Labels or Instructions (A) · APG accessible label always accessibility tree required
switch.name.matches-visible-label Saying the visible label reaches the control. WCAG 2.5.3 Label in Name (A) · APG accessible label always — both the label and the name are observed, never declared accessibility tree + real browser required
switch.name.stable-across-change The name keeps identifying the setting instead of flipping to describe the next action. APG "It is critical the label on a switch does not change when its state changes." the state is operable accessibility tree + real browser advisory
switch.state.exposed What the user hears is what they see. WCAG 4.1.2 (A) · APG "When on … aria-checked … true … an HTML input[type=checkbox] uses the HTML checked attribute instead." always accessibility tree required
switch.description.resolvable No supporting text is silently dropped by a dangling reference. WCAG 1.3.1 Info and Relationships (A) · APG aria-describedby the state renders supporting text DOM required
switch.description.exposed The supporting text reaches the user as the control's description. WCAG 4.1.2 (A) · APG aria-describedby the state renders supporting text accessibility tree required
switch.disabled.exposed A switch the binding marks unavailable is reported as unavailable, instead of looking available. WCAG 4.1.2 (A) the binding declares the state unavailable accessibility tree required
switch.required.declared A switch that must be on declares it before the user submits. WCAG 3.3.2 (A) · WCAG 4.1.2 (A) the state is required DOM required
switch.invalid.exposed A switch in error is reported as being in error. WCAG 4.1.2 (A) the state is in error accessibility tree required
switch.state.pointer-round-trip A pointer turns it on and back off, and the exposed state follows both ways. WCAG 4.1.2 (A) · APG state the user is meant to be able to change the state real browser + accessibility tree required
switch.state.space-round-trip Space turns it on and back off when focused. WCAG 2.1.1 Keyboard (A) · APG "Space: When focus is on the switch, changes the state of the switch." the state is operable and focusable real browser + accessibility tree required
switch.state.survives-an-aborted-press A press slid off the control and released elsewhere leaves it alone, so a misplaced touch can be taken back. WCAG 2.5.2 Pointer Cancellation (A) the user is meant to be able to change the state real browser + accessibility tree required
switch.state.keeps-focus-on-change Changing it leaves focus on it, so a keyboard user is not thrown elsewhere mid-task. WCAG 3.2.2 On Input (A) the state is operable and focusable real browser + accessibility tree required
switch.focus.reachable-and-escapable Tab reaches it and Tab leaves it. WCAG 2.1.1 (A) · WCAG 2.1.2 No Keyboard Trap (A) the state is meant to be in the tab sequence real browser required
switch.state.inoperable A switch the user is not meant to be able to change does not change on click or Space. WCAG 4.1.2 (A) · APG state the user is not meant to be able to change the state real browser + accessibility tree required

Five notes on that table.

switch.state.inoperable is keyed on operability, not on "disabled". A
switch can also be temporarily unchangeable while it waits on the change it
already started — and a second press that slips through queues a change nobody
asked for. Keying it on disabled would have left the busy state, the one case
where "cannot be changed" and "reported disabled" come apart, checked by
nothing.

switch.required.declared sits at the DOM layer, not the accessibility
tree.
Chromium's protocol does not emit a required property for a checkbox
(it reports the resulting constraint-validation invalid instead), so the
honest claim is the declaration itself. Rather than leave a field the package
could only fill with a guess, requiredness is absent from the computed-node type
altogether.

Label stability is advisory, and that is the rule working. The APG is
emphatic — "it is critical the label on a switch does not change when its state
changes" — but it is an APG requirement with no WCAG success criterion behind
it, and no current Astryx record adopts label stability as a contract. AST-020
FR9 says an APG outcome is required only when a current record adopts it, so
this reports rather than gating. The day a record adopts it, the enforcement and
that sentence change together.

switch.name.matches-visible-label reads both sides off the page. It asks
the browser what label is rendered where a person can read it, asks for the
computed name, and compares them. Nothing about it consults the binding — a
criterion a binding could switch off by describing itself would not be a
criterion.

Whether a label is visible takes two questions, because no single API answers
both. checkVisibility is the platform's own answer to "is this rendered at
all", and it walks ancestors, so a label inside a hidden or transparent wrapper
is correctly invisible. What it cannot answer is whether anything of the element
lands on screen — every sr-only recipe stays "visible" to it — so the element is
also sampled: if a point over it resolves to the element, to something inside
it, or to something covering it, it paints there; if every sample resolves to
one of its own ancestors, nothing of it paints and it is clipped away, whatever
its box says.

That distinction matters both ways, and fixtures cover it: a label clipped away
at full size reads as hidden, a decoratively-clipped readable one does not, and
a label under an overlay stays visible — occlusion is not hiding, and treating
it as hiding would silently switch off the criterion that reads it.

The binding's own claim about what each state renders is checked too, but
separately, as a state-inventory assertion in the Chromium binding. A wrong
entry there is a stale inventory, and reporting it as a WCAG 2.5.3 failure would
put a metadata typo and a real accessibility defect in the same bucket.

Comparison is on the label's words, whole and in order — not on characters, and
not on a substring. Astryx renders a required field's label as "Accept terms and
conditions ∙ Required" while the browser computes the name as "Accept terms and
conditions Required": the same words, one decorative separator apart. WCAG
2.5.3's Understanding text is about words ("the words which visually label a
component are also the words associated with the component programmatically"),
so a raw string comparison would have reported that as a failure — and a plain
substring test would have accepted "Sync" as matching "Syncing photos", which is
not a phrase a speech-input user can say.

There is no busy expectation. An earlier draft had one, marked advisory.
It cited WCAG 4.1.2 while its own reasoning said 4.1.2 does not cover a pending
change — the APG switch pattern has no busy clause and no current Astryx record
adopts one either. An expectation with no normative basis is an invented
requirement, so it was removed. Switch keeps its own gating aria-busy test,
and the busy state is still bound: switch.state.inoperable and
switch.focus.reachable-and-escapable both run against it.

Evidence layers, and what is deliberately not run

Each expectation names the layer that characterizes its claim, plus any further
layer its own body reads. An interaction expectation is the usual case:
"clicking turns it on" is a real-browser claim, but reading the resulting state
is an accessibility-tree observation, so it needs both. A harness declares the
layers it can see, and the runner will not run an expectation whose layers a
harness cannot all observe
— it reports unrun, naming the ones that were out
of reach rather than the one the expectation is filed under.

That is why the jsdom lane is small. jsdom renders markup; it does not compute
an accessibility tree, resolve a real tab sequence, or turn a key press into an
activation. Reporting those as passes because the attributes look right is
exactly the substitution the evidence-layer rules exist to prevent, so the jsdom
lane reports accessibility-tree and real-browser as unrun and Chromium
proves them.

Results are reported as separate facts — passes, failures, known failures,
unexpected passes, not-applicable, unrun, exemptions — and a dimension the
pattern owns only part of prints as part-encoded … — remainder → owner,
distinct from a plain exempt. There is no score, and the report is asserted to
contain no percentage: a pattern with one required failure is not "mostly
conformant".

Completeness review: what this pattern does not own

Every dimension of the completeness review is either carried by an expectation
above or exempted here, with the owner and the verification method named.
Silence is not an exemption, and neither is "not applicable" — the contract
refuses both. One dimension, 3.2.2, is part-encoded: an expectation carries
the half the switch owns and a remainder-only exemption names who holds the
rest, both typed rather than asserted in prose, and the report prints it as
part-encoded … — encoded by … ; remainder → … so neither half can be read as
the whole.

1.4.1 and 3.3.1 look like they should be part-encoded too, and are not — see
their rows. In both cases WCAG says plainly that the programmatic outcome this
contract can observe contributes nothing to the criterion.

Dimension Owner Verified by
1.1.1 Non-text Content the binding component the component's own suite (Switch hides its track and thumb, and renders its busy state as text) plus the repository axe audit
1.3.2 Meaningful Sequence the composing page the component's DOM-order tests and page-level review
1.4.1 Use of Color the binding component and the theme The component's forced-colors suite and the visual gate. Deliberately not part-encoded: WCAG is explicit that exposure to assistive technology contributes nothing here — "even if information that is conveyed by color differences is appropriately conveyed to assistive technologies, it does not necessarily pass this criterion".
1.4.3 Contrast (Minimum) the binding component and the theme the repository axe audit over the component stories, plus the visual gate
1.4.11 Non-text Contrast the binding component and the theme the repository axe audit plus the visual gate
2.4.2 Page Titled the page page-level review
2.4.3 Focus Order the composing page page-level review; this contract proves only that the switch is one reachable stop focus can also leave
2.4.4 Link Purpose caller content review of any link a caller places near the control
2.4.6 Headings and Labels caller content and component review review of the label wording; the contract proves a name exists and matches the visible label, not that it describes the purpose well
2.4.7 Focus Visible the interaction-modality architecture record and the binding component the visual gate and the component's focus-ring styling — Astryx switches paint the indicator on the track through an ancestor :has(:focus-visible) condition, so proving it means comparing pixels
2.4.11 Focus Not Obscured the composing page page and overlay review, plus the modal-close visibility guard
2.5.8 Target Size (Minimum) the binding component and the composing page the axe audit's target-size rule, which applies WCAG 2.2's spacing exception across neighbouring targets — a binding rendered on its own cannot see that clearance
3.1.1 Language of Page the page page-level review
3.2.2 On Input encoded in part — switch.state.keeps-focus-on-change; remainder: the caller, for its own onChange A change of context is a change of user agent, viewport, focus, or content that changes the page's meaning. The switch owns exactly one of those — whether activating it moves focus — and that half is encoded. If a caller's onChange navigates or rewrites the page, that is the caller's context change to warn about, verified by integration and page-level review. The contract records both halves rather than letting the encoded one imply the whole criterion.
3.2.4 Consistent Identification the design system this shared contract: every adopter binds to the same expectations
3.3.1 Error Identification the binding component The component's status-message tests. Deliberately not part-encoded: 3.3.1 is satisfied in text — "the error must be indicated in text" — and WCAG says the programmatic half "is not required for this success criterion, but may be covered by other criteria such as 4.1.2", which is where switch.invalid.exposed already sits.
4.1.3 Status Messages the binding component, and the assistive-technology record for the announcement itself the component's live-region regression test, plus real-AT evidence when a change claims what is announced
Forced colors the binding component and the theme the component's forced-colors suite over the compiled CSS, plus manual Windows High Contrast review
Reduced motion the binding component and the theme the component's prefers-reduced-motion guard and the visual gate
AT-facing strings the binding component the repository i18n catalog check and review of the strings rendered for assistive technology

The Switch binding: states

Ten states, each one able to change what the pattern promises. Each declares
what it is, and checked is compared against what the browser exposes — so a
binding cannot pass by rendering on and reporting off. The other declarations
select which expectations apply. States that change only appearance (size, label
position, label spacing, width, theme) cannot change a pattern outcome and are
not bound.

State What it is Story
off the default: labelled, off, operable Core/Switch → Default
on controlled value already on at first render On
on-after-controlled-update the owner turned it on after mount — the value arrived, nobody touched the control ControlledUpdate (new story)
described supporting text under the label WithDescription
label-hidden label read by assistive technology, not rendered visibly WithHiddenLabel
disabled natively disabled, out of the tab sequence Disabled
focusable-disabled disabled with a reason: still focusable so the reason is discoverable, still not operable DisabledWithMessage
required must be on before the form can be submitted Required
invalid required and in error, message attached WithErrorStatus
loading waiting on the change it started: focusable, busy, not operable Loading (new story)

Switch.spec.md lists the same states in its representative-states table and
points its verification map at both lanes.

The Chromium lane drives the checked-in stories, so the reproduction path is
committed rather than living in a throwaway page. Two stories were added because
no checked-in scenario covered the busy state or an owner-driven value change.

What moved, and what stayed

Seven assertions in Switch.test.tsx are now proven by the shared contract at
the same or a stronger layer, so they were removed rather than left with two
owners: renders with label, renders as off by default, renders as on when value prop is true, has role="switch" for accessibility, associates description with switch via aria-describedby, associates status message with switch via aria-describedby, and is disabled when isDisabled prop is true.

One was rewritten rather than deleted. blocks toggling while focusable-disabled asserted two different things: that onChange is not
called, and that the state does not change. The contract owns the second at the
real-browser layer; the first is Switch's own promise, so the test now asserts
only that.

Two more were considered for removal and deliberately kept, because the
shared contract does not prove them at the same or a stronger layer:

  • sets aria-invalid when status type is error. switch.invalid.exposed proves
    a switch in error is reported in error — but the bound state is also
    isRequired and off, and Chromium derives an invalid state from constraint
    validation alone, so that expectation would still pass with Switch's own
    error-status-to-aria-invalid mapping deleted.
  • sets required attribute when isRequired is true. switch.required.declared
    accepts either the native attribute or aria-required, because a non-native
    switch can only offer the latter — and Switch also sets aria-required from a
    form-level default. Only the local test pins isRequired to the native
    attribute, which is what makes the browser block submission.

Everything else stayed, on purpose:

  • callbacks — onChange payloads, onFocus/onBlur, ref forwarding;
  • form participation — htmlName, submitted values, validity with a
    required-and-disabled switch;
  • composition — the disabled-reason tooltip, the label theme target, the
    detached status message and its live-region announcement, the description not
    folding into the accessible name;
  • deliberate component exceptions — that a plain disabled switch is natively
    disabled while one with a disabledMessage stays focusable via
    aria-disabled;
  • styling and layout — forced-colors CSS, RTL thumb travel, label spacing,
    the coarse-pointer hit target, rest forwarding;
  • two states the contract does not reach — a hidden label with a
    description (the combination that used to drop the link), and the aria-busy
    regression.

Known failures

None. The known-failure list is checked in and empty.

Precisely what that means, since "passes in both lanes" would overstate it: in
Chromium, every expectation that applies to a state passes — the DOM,
accessibility-tree, and real-browser checks alike. In jsdom, the DOM-layer
checks run and pass, and every expectation that reads the accessibility tree or
a real browser is reported unrun, naming the layer that was out of reach. The
jsdom lane is a fast regression net over what markup can show; it is not a
second opinion on the outcomes only an engine can observe.

The mechanism is in place and tested rather than assumed: a record pins one
expectation, one binding, one state, one evidence layer, and a distinctive
fragment of the failure it covers, plus the user impact, a public issue, and why
the migration is not the place to fix it. A different message, another state, a
different layer, or a wider failure still fails the build, and an expectation
that starts passing is reported as an unexpected pass so the stale record is
deleted instead of counted as debt forever. Those five behaviours have their own
tests.

One adjacent defect, filed not fixed

Inventorying the states turned up a real bug that this contract does not encode:
#6114 — Switch's busy status
is rendered as a live region born with its content (so it is usually not
announced at all) and as the hardcoded English word Loading (so a non-English
user hears English). Button already does both correctly. It is not recorded as
a contract failure because what an assistive technology actually says is a
real-AT observation, not something a runtime contract can settle.

Also noticed and not touched: injectedRules, dead code in
Switch.test.tsx, and an unused mergeRefs import in Switch.tsx. Both are
pre-existing lint warnings unrelated to this migration.

Mutation proof

An expectation nobody has watched fail is a claim, not a check. Every
expectation is proven against a hand-written fixture that removes exactly its
outcome, and the fixtures are checked in so the proof is repeatable rather than
a one-off note in this description.

The conforming side matters too, and one fixture is there for a specific
reason: a switch that refuses its own change without being disabled. That is
the case where "cannot be changed" and "reported disabled" come apart, and it is
what stops switch.state.inoperable from quietly narrowing back to disabled
states only.

The fixtures are plain HTML with no Astryx in them, because what is under test
is the contract, not the component. Each marks its own subject, so a mutation
flips one expectation instead of making the control unfindable — which would
prove nothing about any of them.

Fixture Which expectation it must break
a checkbox never promoted to a switch role.exposed
a plain element with neither role nor state role.exposed, state.exposed
a switch with no label name.exposed
an aria-label that replaces the visible label name.matches-visible-label
a label that flips to "Turn off…" when the switch goes on name.stable-across-change
changes on the way down, so a press cannot be taken back state.survives-an-aborted-press
throws focus elsewhere the moment it is changed state.keeps-focus-on-change
never changes at all, so there is no change to judge focus across state.keeps-focus-on-change
rendered on while reporting itself off state.exposed
described by an id that resolves to nothing description.resolvable
described by an element that renders no text description.exposed
blocks its own change without saying it is disabled disabled.exposed
marked disabled but still changes state state.inoperable
required or invalid without saying so required.declared, invalid.exposed
never changes state at all state.pointer-round-trip
turns on and cannot be turned back off state.pointer-round-trip, state.space-round-trip
answers a pointer but ignores the keyboard state.space-round-trip
not in the tab sequence focus.reachable-and-escapable
swallows the Tab that would leave it focus.reachable-and-escapable

The one-way fixture is there because half a round trip is the failure that reads
as a pass. A control that turns on and cannot turn off has failed the person
using it just as completely as one that never turned on.

The contract's schema is tested the same way — sixteen cases covering an
expectation with no source, no applicability condition, an unknown evidence
layer, an APG citation with no WCAG outcome behind it, a required class
nothing has adopted, an advisory class with no reasoning, a dimension claimed
twice, and an exemption whose reason is "N/A".

Results

internal/a11y-spec       75 tests   jsdom + node   pass
packages/core Switch     59 tests   jsdom          pass
accessibility contract   45 tests   Chromium       pass

Per state the Chromium report reads, for example:

Switch [focusable-disabled] via chromium
  pass            switch.role.exposed · accessibility-tree · required
  pass            switch.name.exposed · accessibility-tree · required
  pass            switch.name.matches-visible-label · accessibility-tree · required
  pass            switch.state.exposed · accessibility-tree · required
  pass            switch.description.resolvable · dom · required
  pass            switch.description.exposed · accessibility-tree · required
  pass            switch.disabled.exposed · accessibility-tree · required
  not-applicable  switch.required.declared · dom · required
  not-applicable  switch.invalid.exposed · accessibility-tree · required
  not-applicable  switch.state.pointer-round-trip · real-browser · required
  not-applicable  switch.state.space-round-trip · real-browser · required
  not-applicable  switch.name.stable-across-change · accessibility-tree · advisory
  not-applicable  switch.state.survives-an-aborted-press · real-browser · required
  not-applicable  switch.state.keeps-focus-on-change · real-browser · required
  pass            switch.focus.reachable-and-escapable · real-browser · required
  pass            switch.state.inoperable · real-browser · required

pass 9 · fail 0 · known-failure 0 · unexpected-pass 0 · not-applicable 7 · unrun 0
unrun evidence layers: none in this run

and the jsdom lane reports unrun evidence layers: accessibility-tree, real-browser rather than a clean sweep it did not earn.

One footnote on the Chromium lane: transitions are stopped with an explicit
page.emulateMedia({reducedMotion: 'reduce'}), not with configuration. Both
Playwright's use: {reducedMotion: 'reduce'} and Chromium's
--force-prefers-reduced-motion flag leave
matchMedia('(prefers-reduced-motion: reduce)') false in this version —
measured, not assumed — so either one would have read like a safeguard while
doing nothing.

Assistive-technology classification

No real-AT trigger applies. Stated explicitly, because silence is not a
classification.

This change adds tests. It changes no semantic, no focus behaviour, and no
announcement, and it makes no claim that depends on how an assistive technology
exposes or announces anything: every expectation here ends at browser exposure
or browser interaction, and each is proven at the layer that can observe it —
DOM, the computed accessibility tree, or a real engine. Nothing in the contract
reports speech, braille, announcement timing or order, virtual-cursor entry, or
a known AT/browser divergence, and the package says so.

The one Switch outcome that would trigger a real-AT check — whether the busy
state is announced — is deliberately not encoded, and is filed as
#6114.

Consequently there is no real-AT matrix and no stable-release block from this
change.

Browser support

The Chromium lane makes no browser-specific claim and changes no compatibility
promise. It exists because the accessibility tree, real focus, and real
activation need a shipping engine, not because the contract is about Chromium.
Current automated browser coverage in this repository is Chromium, and that
coverage neither defines nor narrows what Astryx supports; a defect reproduced
in any supported browser remains actionable whether or not a lane exists for it.

How to run it

pnpm test                                   # the jsdom lanes
pnpm storybook:build && npx playwright install chromium
pnpm test:a11y-contract                     # the Chromium lane

The Chromium lane also runs inside the accessibility CI job, beside the other
Chromium guards, and that job now also triggers on changes to the contract
itself and to any binding — the bindings live under __tests__/, which the
job's file filter otherwise excludes.

…tch pattern

Reusable, standards-traceable accessibility expectations under AST-020, with
the switch pattern as the first authored contract. Proven positive and negative
against hand-written conforming and deliberately violating fixtures in jsdom
and real Chromium.
…ntract

Adds the first component binding for the reusable accessibility spec tests:
nine representative Switch states, run at the DOM layer in jsdom and at the
accessibility-tree and real-browser layers in Chromium over checked-in stories.
Removes the local Switch assertions the shared contract now owns at a stronger
layer, and keeps callback, form, composition, and styling tests local.

No component behavior changes.
@vercel

vercel Bot commented Sep 7, 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 Sep 7, 2026 6:58pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Sep 7, 2026
- key the inoperability expectation on operability rather than on 'disabled',
  so the busy state — where those two come apart — is actually checked;
- drop the advisory busy expectation: it cited a criterion its own reasoning
  said did not cover it, and nothing current adopts the outcome;
- bind a controlled-update state, where the owner changes the value and nobody
  touches the switch;
- answer WCAG 3.3.1 in the completeness review;
- keep the local aria-invalid and native-required tests: the shared contract
  does not prove either at the same or a stronger layer;
- fail loudly instead of silently when a state declared focusable cannot focus;
- fix a SYNC path, an under-declared @output, a prefix-only path guard, a
  tautological self-test, and drop unused harness surface.
- add a conforming fixture that refuses its change without being disabled, so
  the contract's own suite covers the case the inoperability re-key exists for;
- make the controlled-update mount prove the owner's change actually landed, in
  both lanes, instead of running a wrapper that could do nothing;
- match switch.disabled.exposed's stated outcome to what it applies to;
- drop an orphan comment about the removed busy expectation, share the remote
  control's label, and collapse two alias exports.
@github-actions

github-actions Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

Modified Components

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

Bundle Size Summary

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

Accessibility Audit

Status: No accessibility violations detected.

Visual Regression

Status: No visual change across 2 compared shot(s).


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

- model multi-layer expectations honestly: an interaction expectation declares
  the accessibility tree it reads its answer from, and a harness missing either
  layer reports unrun naming what was out of reach, instead of failing;
- hold motion still with page.emulateMedia — both the Playwright config option
  and Chromium's flag leave prefers-reduced-motion false in this version, so the
  launch arg had been reading like a safeguard while doing nothing;
- run the contract when a Storybook story changes: the Chromium bindings drive
  stories by id, so a rename would have broken them silently;
- make the controlled-update state honest: props.value is the value first
  rendered, and the owner's control moves it to facts.checked;
- declare the package's own dev dependencies rather than leaning on hoisting;
- one CI definition in the Playwright config, one device block, no dead
  outDir/rootDir under --noEmit, one shared remote-control label, and two
  exports nothing consumed removed.
- APG label stability across a round trip: the name must keep identifying the
  setting instead of flipping to describe the next action. APG-only, so it is
  advisory under FR9, with a violating fixture whose label flips;
- WCAG 2.5.2 Pointer Cancellation: press, slide off, release must leave the
  switch alone, against a fixture that changes on the way down;
- WCAG 3.2.2 On Input: the component-owned half — activating must not move
  focus — encoded, against a fixture that throws focus away. The caller's own
  context changes are named as the caller's, not claimed;
- read the visible label off the rendered page instead of trusting the binding's
  declaration, in both directions, comparing words rather than characters
  (Astryx renders 'Label ∙ Required' where the name computes 'Label Required');
- Switch.spec.md gains the controlled-update state and the new outcomes.
- 'directly applicable' now means the PRIMARY source: a supporting citation
  further down the list cannot buy a gate. The label-stability expectation was
  relying on exactly that loophole to be eligible for required;
- a criterion the pattern owns only part of can now say so — an expectation plus
  a remainder-only exemption naming who holds the rest — so 3.2.2's encoded half
  no longer implies the whole;
- compare the label's words whole and in order, not as a substring: 'Sync' was
  matching 'Syncing photos';
- a round trip must reach the opposite value, not merely a different one;
- catch the other ways a label is hidden (opacity, clip, offscreen) and escape
  the id in the label selector;
- correct the PR's evidence-layer column and paste the report the runner really
  prints, in its own order, with nothing dropped.
- keeps-focus-on-change now witnesses the change before judging focus: it reads
  the state before and after, so 'focus stayed put' cannot pass on a switch that
  never moved. The inert fixture fails it for exactly that reason;
- 2.5.3 reads both sides off the page. The binding's claim about what each state
  renders moved to its own inventory assertion, so a metadata typo is reported
  as a stale inventory instead of as a standards failure, and visibleLabel left
  the contract's facts for the binding's own table;
- visibility is the platform's answer now (checkVisibility, which walks
  ancestors) plus a box test for the sr-only recipe, and no clip-path test — a
  decorative clip on a readable label was a false failure. Fixtures for a
  clipped-away label, a decoratively-clipped one, and an ancestor-hidden one;
- clamp the aborted-press release inside the viewport, so where a fixture sits
  cannot turn the gesture into a flake;
- Switch.spec.md's verification map splits semantics, interaction, label
  stability, and inventory, and names the new states and outcomes.
…nating

Three things the last round got wrong, each measured rather than argued:

- a label clipped away at FULL SIZE read as visible, because the box test only
  catches the 1x1 sr-only recipe and the clip test had been dropped. Visibility
  is now checkVisibility plus sampling the element: if every sample resolves to
  one of its own ancestors, nothing of it paints. A decorative clip stays
  visible, and a label under an overlay stays visible too — occlusion is not
  hiding;
- the inventory used startsWith, the exact test the contract forbids two files
  away: 'Sync' passed for 'Sync photos'. It now compares word for word, allowing
  only Astryx's own trailing field marker. Verified by editing an entry and
  watching it fail, and 2.5.3 stayed green — which is the separation working;
- clamping the aborted press could put the release INSIDE a control flush to the
  viewport edge, turning a correct switch into a failure. It now moves away from
  whichever side has more room, and says so plainly if there is nowhere to go.
…ates

- saysInOrder goes back to module-private: the binding's inventory wants exact
  equality, not a subsequence, so it compares word arrays itself. Only
  spokenWords stays exported, and index.ts now says when a helper earns that;
- the interaction row named five states and covers nine. It now says which
  expectation reaches which, checked against what the contract actually runs,
  and label stability enumerates its operable states rather than implying them.
…part-encoded answers

- an expectation that can only discover from the page that it does not apply now
  says so through the runner, which reports not-applicable with the reason. The
  2.5.3 expectation was returning early for a hidden-label state, and a return
  reads as a pass — a claim the outcome was observed. A known-failure record is
  deliberately not consulted for one: an expectation that did not run has
  nothing to record a failure against;
- the factual report tells a part-encoded dimension from a fully exempt one:
  'part-encoded X — remainder -> owner' rather than 'exempt X -> owner';
- 1.4.1 and 3.3.1 join 3.2.2 in the typed model. Their encoded halves are linked
  through covers metadata and their exemptions marked remainder-only, so the
  claim is checked by the constructor rather than asserted in prose.
…et the gates

The last round's 1.4.1 and 3.3.1 part-encoding was wrong, and the standards text
says so outright. 1.4.1: 'even if information that is conveyed by color
differences is appropriately conveyed to assistive technologies, it does not
necessarily pass this criterion.' 3.3.1: the programmatic half 'is not required
for this success criterion, but may be covered by other criteria such as 4.1.2'
— which is where switch.invalid.exposed already sits. Both are plain exemptions
again, now quoting the sentence that decides it. 3.2.2 stays part-encoded: focus
really is one of the four context changes.

Also:
- the part-encoded report line names WHICH expectations carry the encoded half,
  so a reader of the report alone can see it;
- neverExercised() catches an expectation no bound state ever ran — a gate
  nothing exercises is not a gate, and definePattern cannot see this because it
  never sees the bindings. The Switch binding asserts on it.
Nine commits, no conflicts. Two touched files this branch also changes, both
auto-merged cleanly and re-read by hand:

- ci.yml gained a tooling_only lane (#6112, #6113) and moved the heavier test
  lane to a larger runner (#6080). The tooling lane is an exact two-file
  allowlist in change-scope.cjs, so it cannot claim this PR, and the
  accessibility additions — the widened check-components filter, the a11y-spec
  typecheck step, and the test:a11y-contract step in pr-a11y — all survived the
  merge intact;
- deploy.yml's a11y-spec typecheck step is intact.

The 0.6 breaking change (#6118) removes deprecated focus-hook options, an
isImeKeyEvent re-export, and useResizable pixel bounds. Nothing under Switch,
the stories, or internal/a11y-spec references any of them.
Every other step in build-storybook skips when a specialized lane claims the
PR — the checkout and setup those steps depend on skip with them. This one was
added before the tooling lane existed and only knew about docsite-only and
spec-only, so a tooling-only PR would have run pnpm in a job that never checked
out the repo.
One commit, no conflicts: #6124 preserves Resizable bound migration semantics.
It touches the Resizable hook, its codemod, and their tests — nothing this
branch changes, and nothing under Switch or internal/a11y-spec references
useResizable or the pixel-bound options it migrates.
github-actions Bot added a commit that referenced this pull request Sep 7, 2026
@cixzhang
cixzhang marked this pull request as ready for review September 7, 2026 18:59
@cixzhang

cixzhang commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 2b49622

github-actions Bot added a commit that referenced this pull request Sep 7, 2026
@cixzhang
cixzhang merged commit d41bbfa into main Sep 7, 2026
31 checks passed
@github-actions
github-actions Bot deleted the a11y-switch-contract-20260907 branch September 8, 2026 06:22

This branch was successfully deployed

1 active deployment
Preview — 2b496228 Deployed Sep 7, 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