Skip to content

fix(core): link Collapsible trigger to its content via aria-controls - #3707

Merged
cixzhang merged 1 commit into
meta:mainfrom
bhamodi:a11y/collapsible-aria-controls
Jul 10, 2026
Merged

cixzhang merged 1 commit into
meta:mainfrom
bhamodi:a11y/collapsible-aria-controls

Conversation

@bhamodi

@bhamodi bhamodi commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Collapsible's trigger exposed aria-expanded but had no aria-controls, and its content region had no id — so the disclosure relationship (button ↔ the region it shows/hides) was implicit only. Assistive tech couldn't move from the trigger to its controlled content.

This adds a useId()-generated id on the content region and wires aria-controls to it on the trigger button. Purely additive; no behavior/visual change. This matches the pattern already used by MetadataList and SideNav.

Changes

  • Collapsible/Collapsible.tsx: useId() → id on content region + aria-controls on the trigger button; updated the file header doc.

Test plan

  • pnpm -F @astryxdesign/core exec vitest run src/Collapsible/CollapsibleGroup.test.tsx — 33 pass, including a new test:
    • links the trigger to its content region via aria-controls — asserts the trigger's aria-controls is set, resolves to a real element via document.getElementById, and that element contains the collapsible content.
  • Existing Collapsible/CollapsibleGroup behavior tests still green (open/close, controlled, group coordination).
  • tsc --project packages/core/tsconfig.json --noEmit — clean.
  • eslint on changed files — clean.

Notes

Found during a broader a11y audit of core components. Scoped to one fix per PR.

@vercel

vercel Bot commented Jul 9, 2026

Copy link
Copy Markdown

@bhamodi is attempting to deploy a commit to the Meta Open Source Team on Vercel.

A member of the Team first needs to authorize it.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jul 9, 2026
The Collapsible trigger set `aria-expanded` but had no `aria-controls`, and
its content region had no `id`, so the disclosure relationship was implicit
only. Add a `useId()`-generated `id` on the content region and
`aria-controls` on the trigger button.

Test plan:
- pnpm -F @astryxdesign/core exec vitest run src/Collapsible/CollapsibleGroup.test.tsx
  (33 pass, incl. new "links the trigger to its content region via aria-controls")
- core typecheck + eslint on changed files: clean

@cixzhang cixzhang 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.

Thanks @bhamodi — completes the Collapsible disclosure pattern (aria-controls + content id), mirrors MetadataList, 33/33 green. 🙏

@cixzhang
cixzhang merged commit 36ecca5 into meta:main Jul 10, 2026
14 of 15 checks passed
@bhamodi
bhamodi deleted the a11y/collapsible-aria-controls branch July 15, 2026 01:47
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.

2 participants