Repository navigation
fix(lab): accessible names and data-table fallbacks for charts - #4382
Merged
Merged
Conversation
bhamodi
requested review from
cixzhang,
ejhammond and
imdreamrunner
as code owners
July 26, 2026 05:06
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
github-actions
Bot
requested review from
cvkxx,
ernestt,
kentonquatman and
rubyycheung
July 26, 2026 05:06
Contributor
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 |
ernestt
approved these changes
Jul 28, 2026
bhamodi
force-pushed
the
a11y/lab-chart-names
branch
from
July 30, 2026 07:59
a34830f to
c8fd4ee
Compare
cixzhang
approved these changes
Jul 30, 2026
cixzhang
left a comment
Contributor
There was a problem hiding this comment.
Nice! I think geo had this so good to see it brought in.
cixzhang
enabled auto-merge (squash)
July 30, 2026 22:09
AKnassa
added a commit
to AKnassa/astryx
that referenced
this pull request
Aug 27, 2026
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 (meta#4382) means chart label and tooltip queries scope to the svg; useTooltip's touch guard is per pointer type (meta#5248) and a controlled tooltip reports Escape through onHide (meta#4881); TableHeaderCell dividers are logical inline-end properties (meta#4434).
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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Charts were invisible to assistive technology (a11y scan finding #3, severity SERIOUS, WCAG 1.1.1 Non-text Content). The root
<svg>elements of the lab charts had norole="img", no accessible name, no<title>, and no text alternative for the plotted data -- a screen reader user got nothing at all from a Chart or RadialChart, and Sankey was only named when it happened to need horizontal scrolling.This PR gives every chart root an accessible name and, for modest datasets, a visually hidden data-table text alternative (using the core
VisuallyHiddenprimitive), so the underlying values are readable by assistive tech.Lab has no i18n mechanism (other lab components use
Intlfor dates only, English strings elsewhere), so defaults are English and every chart accepts alabelprop override for localized names. This is documented on each prop.Changes
Chart(packages/lab/src/Chart/Chart.tsx) -- svg now hasrole="img"+aria-label. Newlabelprop; defaults to"Chart of {yKeys} by {xKey}". Visually hidden table (x column + one column per y key) rendered when rows x series <= 100 points (documentedMAX_TABLE_POINTScutoff -- beyond that a table is more noise than signal, name-only).RadialChart(packages/lab/src/Radial/RadialChart.tsx) -- svg now hasrole="img"+aria-label. Newlabelprop; defaults to"Radar chart of {axes}"(spider) /"Pie chart of {valueKey}"(pie). Hidden table: pie mode lists label/value/percentage per slice; spider mode lists one row per series across the axes (row header uses the same first-string-field heuristicRadialAreauses fordataKey). Same <=100-point cutoff.SankeyChart(packages/lab/src/Sankey/SankeyChart.tsx) -- svg now hasrole="img"+aria-labelin both the scrolling and non-scrolling paths (previously only the scroll wrapper from fix(lab): accessibility cleanup for CodeEditor, SankeyChart, and Schedule #3549 was named, and only when scrolling). Newlabelprop (default'Sankey chart') feeds both the svg and the scroll region. Hidden From/To/Value table of links (node labels resolved from node defs), <=100 links cutoff.Chartv2 (packages/charts/src/Chart.tsx) -- had the same gap, partially:aria-labelonly whentitlewas set, and neverrole="img". Now alwaysrole="img"witharia-label = title ?? "Chart of {series labels} by {xKey}"(per the convention, the existingtitleprop is preferred as the name -- no new prop). Same hidden data table (columns = union of primary series dataKeys, utility marks excluded), <=100-point cutoff.vitest.config.ts-- addedpackages/chartsto theuitest project (it previously fell through to the DOM-lessnodeproject, exactly the migration path the config's partitioning comment prescribes) and mapped the bare@astryxdesign/corespecifier to source so charts' runtime core imports resolve in tests.Table-vs-name-only rationale per chart: Chart/Radial/charts-v2 receive structured rows/slices, so a table is meaningful; Sankey's graph is flattened to its links (source, target, value), which is the standard text serialization of a flow diagram.
Test plan
New tests (15 new assertions-bearing tests across 4 files) were written first and confirmed failing pre-fix:
15 failed | 6 passed(the 6 = 2 pre-existing Sankey scroll tests + 4 over-cutoff negatives that are trivially true pre-fix).Post-fix:
prettier --checkon all 9 changed files -- cleaneslinton all 9 changed files -- cleantsc --project packages/lab/tsconfig.json --noEmit-- 0 errorstsc --project packages/charts/tsconfig.json --noEmit-- 0 errorsvitest run packages/lab/src/Chart packages/lab/src/Radial packages/lab/src/Sankey packages/charts/src-- 8 files, 47 tests passedvitest run packages/lab-- 21 files, 268 tests passednode scripts/check-changesets.mjs-- passes (44 changesets valid)Coverage per chart: svg has
role="img"+ accessible name (default and customlabel); data table renders with correct values for a small dataset and is visually hidden (StyleX clip class, notdisplay:none/hidden); table skipped over the cutoff; Sankey named in both scroll and no-scroll paths, custom label applied to both svg and scroll region.Notes
@astryxdesign/laband@astryxdesign/chartsareprivate: true;scripts/check-changesets.mjsrejects them ("private/ignored and cannot be released"), verified empirically. Per the checker's guidance, private packages are changeset-exempt.ThreeDChartis intentionally not touched here -- it is handled in a separate PR (fix(lab): ThreeDChart accessible name, pausable rotation, keyboard camera #4381) using the samelabel+role="img"convention.