Repository navigation
fix(lab): accessibility cleanup for CodeEditor, SankeyChart, and Schedule - #3549
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR No new or modified components detected. Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
| * Accessible name for the editable region. Defaults to a name derived from | ||
| * `language` (e.g. "typescript code editor") or "Code editor". | ||
| */ | ||
| ariaLabel?: string; |
There was a problem hiding this comment.
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 () => { |
There was a problem hiding this comment.
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.
|
One thing to double-check: the PR summary describes an optional |
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
ariaLabelprop onCodeEditor.@astryxdesign/labis 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 anaria-labelon the component would not name the textbox.Fix: Added an optional
ariaLabelprop and applied it to the<code>element, defaulting to a name derived fromlanguage(e.g."typescript code editor") or"Code editor".Testing: New
CodeEditor.test.tsxasserts the textbox is reachable by its language-derived name and that an explicitariaLabeloverrides 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
needsScrollis true, the scroll container now getstabIndex={0}plusrole="group"andaria-label="Sankey chart". When the chart fits, no extra attributes are added. Deliberately avoidedrole="region"to steer clear of landmark-uniqueness issues.Testing: New
SankeyChart.test.tsxdrives a mockedResizeObserverto 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:
ScheduleFramerenders its title as an<h2>(Heading level={2}). The list day headings (ListView) and monthly weekday headings (MonthlyView) wereHeading level={4}, so the heading order jumped h2 to h4, skipping h3.Fix: Dropped both from
level={4}tolevel={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 viaScheduleFrame; no consumer context is required. (TimeGridView'slevel={4}heading lives inside anaria-hiddensubtree, so it is not part of the accessibility tree and is out of scope.)Testing: Added two cases to
Schedule.test.tsxasserting the monthly and list views render level-3 headings and no level-4 headings.Verification
pnpm -F @astryxdesign/lab typecheck- exit 0pnpm exec eslint <changed files>- exit 0pnpm 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