Skip to content

fix(lab): accessibility cleanup for CodeEditor, SankeyChart, and Schedule - #3549

Merged
cixzhang merged 3 commits into
mainfrom
navi/fix/lab-a11y-cleanup
Jul 8, 2026
Merged

cixzhang merged 3 commits into
mainfrom
navi/fix/lab-a11y-cleanup

Conversation

@cixzhang

@cixzhang cixzhang commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Lab a11y cleanup addressing three axe-core findings from a Storybook audit. All three are in packages/lab (experimental components, lower a11y bar than core), but the fixes are cheap and the violations are real. Part of the ongoing accessibility program (#3343).

No consumer-facing API break; the only new surface is an optional ariaLabel prop on CodeEditor. @astryxdesign/lab is a canary-only (private) package, so there is no changeset (consistent with prior lab-only PRs).

Findings and fixes

1. CodeEditor - aria-input-field-name (serious)

Problem: The editable region is a <code role="textbox" aria-multiline="true" contentEditable> with no accessible name. Consumer-passed props spread onto the root <div>, not the inner <code>, so even an aria-label on the component would not name the textbox.

Fix: Added an optional ariaLabel prop and applied it to the <code> element, defaulting to a name derived from language (e.g. "typescript code editor") or "Code editor".

Testing: New CodeEditor.test.tsx asserts the textbox is reachable by its language-derived name and that an explicit ariaLabel overrides it.

2. SankeyChart - scrollable-region-focusable (serious)

Problem: When the chart is wider than its container it wraps the SVG in a div with overflowX: auto, but that scroll container was not keyboard-focusable, so keyboard users could not scroll it.

Fix: When needsScroll is true, the scroll container now gets tabIndex={0} plus role="group" and aria-label="Sankey chart". When the chart fits, no extra attributes are added. Deliberately avoided role="region" to steer clear of landmark-uniqueness issues.

Testing: New SankeyChart.test.tsx drives a mocked ResizeObserver to force the scroll case and asserts the region is focusable, and asserts no focusable region appears when the chart fits.

3. Schedule - heading-order (moderate)

Problem: ScheduleFrame renders its title as an <h2> (Heading level={2}). The list day headings (ListView) and monthly weekday headings (MonthlyView) were Heading level={4}, so the heading order jumped h2 to h4, skipping h3.

Fix: Dropped both from level={4} to level={3} so the hierarchy is h2 then h3 with no skip. This is a self-contained fix because the Schedule renders its own top-level heading via ScheduleFrame; no consumer context is required. (TimeGridView's level={4} heading lives inside an aria-hidden subtree, so it is not part of the accessibility tree and is out of scope.)

Testing: Added two cases to Schedule.test.tsx asserting the monthly and list views render level-3 headings and no level-4 headings.

Verification

  • pnpm -F @astryxdesign/lab typecheck - exit 0
  • pnpm exec eslint <changed files> - exit 0
  • pnpm exec vitest run packages/lab/src/CodeEditor packages/lab/src/Sankey packages/lab/src/Schedule - 21 passed (3 files)
  • pnpm run check:changesets - exit 0

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

vercel Bot commented Jul 4, 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 4, 2026 3:30pm

Request Review

josephfarina
josephfarina previously approved these changes Jul 4, 2026
@github-actions

github-actions Bot commented Jul 4, 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.

No new or modified components detected.

Bundle Size Summary

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

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 Jul 4, 2026
@cixzhang
cixzhang marked this pull request as ready for review July 4, 2026 13:28
thedjpetersen
thedjpetersen previously approved these changes Jul 4, 2026

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

Approved.

* Accessible name for the editable region. Defaults to a name derived from
* `language` (e.g. "typescript code editor") or "Code editor".
*/
ariaLabel?: string;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We don't typically differentiate displayed label vs accessible labels. So this can just be label and be required

expect(screen.queryByText('Outside range')).not.toBeInTheDocument();
});

it('renders monthly weekday headings at level 3 so heading levels do not skip', async () => {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It seems like the assumption here is based off storybook and not necessarily representative of the actual real cases. We likely want to make the heading levels within the schedule modifiable

…eadingLevel configurable

CodeEditor:
- Rename ariaLabel → label (required) — no differentiation between
  displayed and accessible labels per project convention.

Schedule:
- Add headingLevel prop (default 3) so consumers can set heading
  levels appropriate to their context.
- All views (list, monthly, time-grid) read from context.
The label prop is now required; two story usages (CodeEditorPerf and
CodeEditorTheme second instances) still lacked it, breaking the storybook
typecheck.

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

Approved.

@josephfarina

Copy link
Copy Markdown
Contributor

One thing to double-check: the PR summary describes an optional ariaLabel prop that defaults to a language-derived name, but the diff actually adds a required label: string on CodeEditorProps with no default. The code path is fine (all three storybook callsites are updated and the test passes), but the required prop is a stricter API than the description implies — any external lab consumer of CodeEditor will now get a type error until they add label. If that's intended, worth updating the summary; if you meant it to be optional with a fallback, the prop should be label?: string with a default. Approving either way.

@cixzhang
cixzhang merged commit 8f64eb9 into main Jul 8, 2026
16 of 17 checks passed
@cixzhang cixzhang added needs:design-review Affects visuals — Design should review type:fix labels Jul 8, 2026
@github-actions
github-actions Bot deleted the navi/fix/lab-a11y-cleanup branch July 12, 2026 06:57

This branch was successfully deployed

1 active deployment
Preview — dbb710cd Deployed Jul 4, 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. needs:design-review Affects visuals — Design should review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants