Skip to content

fix(core): wire aria-controls on ChatComposerDrawer toggle - #3996

Merged
cixzhang merged 1 commit into
meta:mainfrom
bhamodi:a11y/chatcomposerdrawer-controls
Jul 23, 2026
Merged

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

Conversation

@bhamodi

@bhamodi bhamodi commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Summary

ChatComposerDrawer's collapse toggle (role="button", packages/core/src/Chat/ChatComposerDrawer.tsx) exposed aria-expanded but no aria-controls, and the drawer's content wrapper had no id, so assistive tech had no way to jump from the toggle to the region it shows/hides.

This wires up the standard disclosure linking, matching the repo's existing precedents: Collapsible (36ecca5, #3707), Banner (64f07c9, #3719), and CodeBlock (d7bde21, #3723), plus the prior Chat disclosure work in ChatToolCalls (e45d9ae, #3720):

  • A stable useId()-generated id is applied to the drawer's content wrapper.
  • The toggle sets aria-controls={contentId} alongside its existing aria-expanded.

Unlike Banner (whose region unmounts and therefore conditions aria-controls on it being mounted), the drawer's content stays mounted while collapsed -- it is hidden via the grid-template-rows: 0fr collapse -- so aria-controls is unconditional here, mirroring the Collapsible precedent. Purely additive; no behavior or visual change.

Changes

  • Chat/ChatComposerDrawer.tsx: generate contentId via useId(), set aria-controls={contentId} on the toggle, apply id={contentId} to the content wrapper; note the disclosure wiring in the file header.
  • Chat/ChatComposerDrawer.test.tsx (new, colocated -- the component previously had no tests): covers aria-controls resolution and aria-expanded toggling.
  • .changeset/chatcomposerdrawer-controls.md: patch changeset for @astryxdesign/core.

Test plan

  • node_modules/.bin/vitest run --root . packages/core/src/Chat -- 140 pass across 14 files, including three new tests in ChatComposerDrawer.test.tsx:
    • links the toggle to the drawer content via aria-controls -- asserts the toggle's aria-controls resolves via document.getElementById to the element containing the drawer content.
    • keeps aria-controls resolvable while collapsed (content stays mounted) -- same resolution assertion with defaultIsCollapsed.
    • toggles aria-expanded when the toggle is activated -- true -> false -> true across clicks.
  • Pre-fix: the two aria-controls tests fail on main (aria-controls is null); the aria-expanded test passes (regression guard).
  • Full core suite: node_modules/.bin/vitest run --root . packages/core -- 4584 pass (204 files), no pre-existing failures.
  • node_modules/.bin/tsc --project packages/core/tsconfig.json --noEmit -- clean.
  • eslint + prettier --check 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 15, 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, Comment Jul 23, 2026 8:35pm

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jul 15, 2026
@github-actions github-actions Bot added community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge labels Jul 15, 2026
@github-actions

github-actions Bot commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

Modified Components

Chat
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 5243 -
Complexity N/A Very High (425) -

Bundle Size Summary

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

Accessibility Audit

Status: 1 accessibility violation(s) found — 1 serious.

Chat - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 2/8 stories · Learn more
    • WCAG: 1.4.3 (Level AA)

Generated by PR Enrichment workflow | View full report

@github-actions github-actions Bot removed the needs:code-review High-risk change (new package/component/API) — needs human code review before merge label Jul 23, 2026
@cixzhang
cixzhang merged commit cf4c0a4 into meta:main Jul 23, 2026
21 checks passed
@github-actions
github-actions Bot deleted the a11y/chatcomposerdrawer-controls branch July 24, 2026 08:12
cixzhang pushed a commit that referenced this pull request Sep 3, 2026
…sted viz packages and hooks (#4295) (#4377)

* test: cover the viz packages and five core hooks

packages/charts and packages/vega had no functional tests at all, and
packages/lab's chart primitives (Chart*, Radial*, ThreeD*, Sankey*,
SVGIcon) rendered nothing under test. Add colocated tests for each, plus
renderHook tests for the three useCalendar* hooks, useCollapsible and
useTableFilterState.

Harness: charts and vega were falling through to the `node` vitest
project, which has no jsdom, no StyleX transform and no jest-dom, so
their tests could never have run there. Move both into the `ui` project
and give vega the test scripts the other packages already have.

53 test files, 307 tests. Verified: full suite 7943 pass / 430 files,
still green with packages/core/dist absent (the cold-CI path, which
charts needs because it imports core by bare name for values); 8 sampled
mutations across all four packages, each killed by exactly the new test.

Refs #4295

* test: cover remaining core hooks and components

Finishes the functional-coverage sweep started in 64d9ea3. Adds
renderHook tests for useScrollLock, useLightbox, useChatPasteAsToken,
useImperativeAlertDialog, useTranslator and useTooltip, plus colocated
tests for the components that had none: CommandPaletteEmpty,
InputClearButton, TypeaheadItem, ChatSendButton, PowerSearchToken,
PowerSearchFilterEditor and TableHeaderCell.

Two of the issue's nine "zero-test" components already had tests
(ChatComposerDrawer, MobileNavToggle, from #3996 and #3721), so the
inventory is smaller than the issue states.

Extracts the StyleX declaration read-back helper that three of these
files each needed into __tests__/stylexDeclarations.ts rather than
landing a third copy.

Two branches are deliberately left uncovered, with the reason recorded
next to them: the ignored-onOpenChange(true) guards in useLightbox and
useImperativeAlertDialog are unreachable through the public surface,
and reaching into element props to force them both breaks the repo's
no-react-introspection lint rule and asserts a value that is already
settled. useTooltip's focus paths are also omitted -- jsdom resolves
:focus-visible as :focus, so those tests would pass with the gate
deleted.

Verified: 8101 tests / 443 files green, eslint and prettier clean,
core typecheck clean; three sampled mutations (the send-button variant
ternary, CommandPaletteEmpty's xstyle merge, useTooltip's touch
suppression) each killed by exactly one new test.

Refs #4295

* test: port the branch's remaining assertions onto main's test files

The eight add/add conflicts resolved to main's files in the merge; this
ports back only the assertions main does not cover and that still hold
today (render gates and sizing, layer groups and masks, style restore,
registry glyph, xstyle forwarding, context guards). Duplicates of main's
coverage are dropped rather than kept twice.

Four files went stale over the 815-commit gap and follow today's
behavior: the hidden data-table fallback (#4382) means chart label and
tooltip queries scope to the svg; useTooltip's touch guard is per
pointer type (#5248) and a controlled tooltip reports Escape through
onHide (#4881); TableHeaderCell dividers are logical inline-end
properties (#4434).

* test(calendar): assert month labels as English literals

CI's lint job fails on the one raw Intl call left in these tests:
main's no-raw-intl-locale rule keeps its test-oracle allowlist inside
the rule, and this file is not on it. The oracle was also the wrong
side: with no InternationalizationProvider mounted, useLocale() resolves
to 'en', so the hook's labels never followed the machine locale that
Intl.DateTimeFormat(undefined) reads. Literal 'April 2026' style
assertions match Calendar.test.tsx and drop the Intl dependency.

This branch was successfully deployed

1 active deployment
Preview — 4c1d9634 Deployed Jul 23, 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. community Authored by a community contributor (not on the eng/design team)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants