Skip to content

fix(indicator): ship the a11y type change as breaking, with a codemod (#4937) - #4938

Closed
cixzhang wants to merge 2 commits into
mainfrom
fix-4937
Closed

cixzhang wants to merge 2 commits into
mainfrom
fix-4937

Conversation

@cixzhang

Copy link
Copy Markdown
Contributor

Fixes #4937. Found by the independent re-audit under rubric v1.3, not by me.

The BLOCK

#4921 Omitted four members from the exported IndicatorProps and shipped it as a patch under [fix]. That is a retyped public export, which rubric P11 names explicitly at BLOCK severity: it needs [breaking] → minor and a codemod. The changeset even advertised the break in prose ("passing role is a compile error"). check:changesets only enforces category↔bump, so CI could not see it.

My own PR three commits earlier set the precedent I then ignored: remove-dropdown-menu-radio-dot-target shipped [breaking] + minor + a codemod for a quieter break — silent at runtime, rather than red at compile time.

  • Changeset re-issued as [breaking] / minor.
  • New codemod remove-indicator-a11y-props, staged in transforms/next.

The codemod reaches both shapes, which is the part worth reviewing. A direct <CheckIndicator … /> is easy; the documented themeable form is not:

const Mark = useIndicator('check');
return <Mark state="checked" tabIndex={0} aria-label="chosen" />;

No indicator name appears in that JSX at all, so a name-matching transform would sail past it. It resolves locals through useIndicator()/getIndicator() too, pinned by a test.

It removes rather than rewrites — there is nowhere to move these props to — and leaves a TODO at every site, because "the owning control already carries the name" is a claim about the call site that a codemod cannot verify. If the indicator was the only thing naming the control, the name has to move there, and a human has to decide that.

Two FIXes from the same audit

tabIndex joins the omission list, and is dropped at runtime. This is a trap #4921 created: aria-hidden became unconditional, so a forwarded tabIndex is now a focusable node inside a hidden subtree. Before that diff a consumer could pair tabIndex with aria-hidden="false" and be valid.

Measured in real Chromium with the repo's own axe: 0 → 1 aria-hidden-focus violation the moment it is forwarded. My own jsdom probe had reported none — jsdom cannot judge focusability, which is worth remembering about that harness.

Indicator.doc.mjs:55 still told a replacement to render children "when present" — verbatim the wording #4921 replaced in bestPractices because "present" is the trap. (Not an X21 BLOCK: X21 enumerates examples[].code, usage.bestPractices and @example, and a props[].description is none of the three. Worth telling the rubric owner that the identical sentence is BLOCK-able one field away.)

And a correction to something I claimed

"Passing role is a compile error" holds only for a literal attribute. A spread — the ordinary host idiom — bypasses excess-property checking for every member, role included:

const hostile = {role: 'checkbox', tabIndex: 0};
<CheckIndicator state="checked" {...hostile} />   // compiles clean

So the type states intent and catches the literal; ordering and the codemod do the enforcing. A test pins that, deliberately without @ts-expect-error, so it starts failing the day TypeScript changes its mind.

Test plan

4 new tests red against origin/main:

× CheckIndicator (glyph path)    refuses a tab stop inside its hidden subtree
× CheckIndicator (children path) refuses a tab stop inside its hidden subtree
× CheckboxIndicator              refuses a tab stop inside its hidden subtree
× RadioIndicator                 refuses a tab stop inside its hidden subtree
   Tests  4 failed | 40 passed (44)

Codemod: 5 cases — direct call site, the useIndicator alias, other components left alone, no-op on indicator-free files, idempotent. Assertions match the attribute form, not a bare substring, because the TODO comment names the props it removed.

Suites: 1134 pass across Indicator + every consumer + the codemods; core tsc clean; typecheck:docs clean; CI=true eslint --no-cache 0/0; check:changesets 60 valid; check:sync clean.

Ledger

Recorded at 82.4 / C (653729439e, rubric v1.3) with P11 as the one open BLOCK — wiki 3884786. This closes it; projected 87.1 / B. I will re-audit and re-record once this merges.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Aug 12, 2026
@vercel

vercel Bot commented Aug 12, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
astryx Ready Ready Preview Aug 12, 2026 4:00pm

Request Review

@github-actions

github-actions Bot commented Aug 12, 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

Indicator (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 558 -
Complexity N/A High (26) -

Bundle Size Summary

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

Accessibility Audit

Status: No accessibility violations detected.


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

github-actions Bot added a commit that referenced this pull request Aug 12, 2026
#4921 Omitted four members from the exported IndicatorProps and shipped
it as a `patch` under [fix]. That is a retyped public export, which
rubric P11 names explicitly and puts at BLOCK: it needs [breaking] +
minor + a codemod. The changeset even advertised the break in prose.
check:changesets only enforces category-to-bump, so CI could not see it.

My own PR three commits earlier set the precedent I then ignored:
remove-dropdown-menu-radio-dot-target shipped [breaking] + minor + a
codemod for a strictly QUIETER break -- silent at runtime rather than red
at compile time.

Found by an independent re-audit under rubric v1.3, not by me.

  - changeset re-issued as [breaking] / minor.
  - New codemod remove-indicator-a11y-props, staged in transforms/next.
    It reaches BOTH shapes: a direct <CheckIndicator .../> and the
    documented `const Mark = useIndicator('check')` form, where no
    indicator name appears in the JSX at all. Removal, not rewriting --
    there is nowhere to move these props to -- and every removal leaves a
    TODO, because "the owner already carries the name" is a claim about
    the call site a codemod cannot verify.

Also closes two FIXes from the same audit:

  - tabIndex joins the omission list, and is dropped at runtime. This
    diff created the trap: aria-hidden became unconditional, so a
    forwarded tabIndex is now a focusable node inside a hidden subtree.
    Measured in real Chromium: axe aria-hidden-focus 0 -> 1 violation.
    My own jsdom probe had reported none -- jsdom cannot judge
    focusability, which is worth remembering about that harness.
  - Indicator.doc.mjs:55 still told a replacement to render children
    "when present" -- verbatim the wording #4921 replaced in
    bestPractices BECAUSE "present" is the trap.

And corrects an overstatement of mine: "passing role is a compile error"
holds only for a literal attribute. A spread -- the ordinary host idiom --
bypasses excess-property checking for every member, `role` included. The
type states intent; ordering and the codemod do the enforcing. A test now
pins that, deliberately without @ts-expect-error, so it fails the day
TypeScript changes its mind.

Verified: 4 new tests red against origin/main; 1134 pass across the
subject, every consumer and the codemods; core tsc, typecheck:docs and
strict lint clean; check:changesets 60 valid.
… typecheck

The remove-indicator-a11y-props transform tripped the strict CLI
typecheck: the TODO helper's `names` parameter and the `removed`
accumulator were implicitly `any`. Annotate both so
`tsc --project tsconfig.strict.json` passes.
@cixzhang

Copy link
Copy Markdown
Contributor Author

Closing — the premise is wrong, and Cindy caught it.

IndicatorProps has never shipped. Measured:

  • @astryxdesign/[email protected] (the published version) was released 2026-08-05 and its exports map has no ./Indicator subpath.
  • Indicator landed 2026-08-11 in feat(theme): add themeable indicators #4712, whose changeset themeable-indicators.md is still pending in .changeset/ — so no release has consumed it.

The whole layer ships for the first time in the next release. Omitting props from a type no consumer can have installed breaks nobody, so all three things this PR did are wrong:

  • [breaking] / minor — would bump core to 0.4.0 and write a changelog entry warning consumers about a removal from an API they never had.
  • The codemod — would run against consumer code that cannot contain an indicator call site.
  • The framing — there is no migration, because there is nothing to migrate from.

The original [feature] / patch changeset on #4712 is the correct and sufficient record: Indicator arrives complete, with the a11y props already omitted.

Three fixes in here are real and independent of the changeset question, so I am re-landing them as a plain patch (see the follow-up PR):

  • tabIndex omitted and dropped at runtime — a genuine trap, measured in real Chromium going from 0 to 1 axe aria-hidden-focus violation once forwarded.
  • Indicator.doc.mjs:55 still said "render children when present" — the wording fix(indicator): the decorative contract is not a caller's to switch off (#4918) #4921 replaced elsewhere because "present" is the trap.
  • The changeset's "passing role is a compile error" overstated the type: true for a literal attribute, false for a spread.

@cixzhang cixzhang closed this Aug 12, 2026
cixzhang added a commit that referenced this pull request Aug 13, 2026
* fix(indicator): a forwarded tabIndex no longer puts a tab stop in a hidden subtree

Indicators are unconditionally aria-hidden, so a focusable one is a
focusable node inside a hidden subtree -- axe aria-hidden-focus, measured
in real Chromium going from 0 violations to 1 the moment tabIndex is
forwarded. #4921 created that trap: before it, a consumer could pair
tabIndex with aria-hidden="false" and be valid.

`tabIndex` joins the props IndicatorProps omits, and is dropped at
runtime by a small internal helper for the case the type cannot see:
TypeScript exempts hyphenated JSX attributes from excess-property
checking, and a spread -- `<Mark {...props} />`, the ordinary host idiom
-- bypasses the check for every member. Only tabIndex is removed;
aria-hidden is settled by attribute order, and role/aria-label are inert
inside a hidden subtree, so they are left alone rather than silently
deleted.

This is the salvage from #4938, which was closed: that PR escalated the
same change to a [breaking] changeset plus an `astryx upgrade` codemod on
the theory that IndicatorProps is public API. It is not, yet --
[email protected] published 2026-08-05 with no ./Indicator subpath, Indicator
landed 2026-08-11, and its changeset is still pending, so the layer ships
for the first time next release. Nothing to break, nobody to migrate.
Plain [fix] patch is the honest record.

Closing that PR also surfaced a bug in it: the type half of this change
was lost in a revert/restore during its development and never made it
into the commit, while its changeset advertised it. Only the runtime drop
shipped, and the tests passed because they exercise runtime. Both halves
are here, and I checked the type change survived this time.

Also corrects two doc claims, both from the same audit:
  - Indicator.doc.mjs:55 still said a replacement must render children
    "when present" -- verbatim the wording #4921 replaced in
    bestPractices BECAUSE "present" is the trap.
  - "passing role is a compile error" holds only for a literal
    attribute; a spread bypasses the check. A test pins that,
    deliberately without @ts-expect-error, so it fails the day
    TypeScript changes its mind.

Verified: 4 new tests red against origin/main; 391 pass across the
subject and every consumer; core tsc, typecheck:docs and strict lint
clean.

* Slim to the type: drop the runtime strip and its module

Cindy's review, and she is right on both counts.

Nobody sets tabIndex on an indicator -- grepped every call site in core,
zero. And `tabIndex` is a plain JS identifier, so excess-property
checking applies and the Omit rejects the literal on its own; I verified
the @ts-expect-error is consumed. The type was already doing the work.

So stripSmuggledProps.ts is deleted and all three components go back to a
plain {...rest}. What is left is one word in an existing Omit.

The module was also inconsistent, which I should have noticed while
writing it: we deliberately do NOT strip `role` or `aria-label` -- they
are inert inside an aria-hidden subtree -- so singling out tabIndex for a
runtime guard defended one spread-only case while leaving its siblings,
at the cost of a module and an indirection.

The runtime tests go with it; the spread case is now documented in the
test that shows it compiling, with the reason it is left alone.

Diff is now: one word in types.ts, one doc sentence, tests, changeset.
No .tsx source change at all.
@github-actions
github-actions Bot deleted the fix-4937 branch August 13, 2026 06:36

This branch was successfully deployed

1 active deployment
Preview — a2e3006c Deployed Aug 12, 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

1 participant