Repository navigation
fix(TreeList): forward BaseProps attributes to the tree element (#5476) - #5493
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 Modified ComponentsTreeList (@astryxdesign/core) · View in Storybook
Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Visual RegressionStatus: No visual change across 2 compared shot(s). 32 shot(s) have no baseline yet and were not compared. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
cixzhang
left a comment
There was a problem hiding this comment.
Thanks — the diagnosis is right, and List names correctly now. Two things before it lands, plus a changeset.
The tree still can't be named. aria-label lands on the layout <div>; the <ul> that carries role="tree" gets nothing, so <TreeList aria-label="File tree"> still announces as an unnamed tree. The new test asserts on container.firstElementChild — that div. Chromium's a11y tree:
A caller can now displace role="list". Your body promises role forwards, and {...restProps} is spread after role="list" — so <List role="listbox"> wins and the role restoring VoiceOver's "list, N items" is gone. API Conventions: contract props go "after {...rest} … so consumer input can't clobber the contract."
For TreeList, pull aria-label/aria-labelledby out of the rest onto the <ul role="tree">.
#5288 takes the List half and goes first. Want to narrow this to TreeList and land it on its own?
[Reviewed by Robohands]
…#5476) TreeList destructured a fixed set of props with no rest spread, so every BaseProps attribute (aria-*, role, tabIndex, id, event handlers) was dropped and never reached the DOM. A tree without a visible header could not be named at all - a screen reader announced an unnamed tree with no way to know which tree it was. The component now spreads the remaining props onto the root element and routes aria-label/aria-labelledby onto the <ul role="tree"> itself, so <TreeList aria-label="File tree"> names the tree. A consumer-supplied aria-labelledby wins over the internal header association, and the contract role="tree" is written after the rest spread so a consumer cannot displace it. Adds regression tests asserting aria-label reaches the tree element and id reaches the root.
94e8ee7 to
eb0d3e5
Compare
|
Thanks for the review, @cixzhang - the diagnosis was spot on, and I took both points to adjust the commit. Narrowed to TreeList and landed both fixes.
The contract Added a changeset. The |
cixzhang
left a comment
There was a problem hiding this comment.
Thanks, this is much closer. The List half is resolved, and aria-label now lands on the right <ul role="tree">.
One path still needs the same precedence as #5288: when TreeList renders a visible header, that generated header id should keep naming the tree. Right now an external aria-labelledby replaces it, so AT hears a different name than the visible header.
Can you make the header id win when header exists, and only use caller aria-labelledby on the headerless path? If you’d rather talk it through with someone, we’re in Discord.
[Reviewed by Robohands]
…ia props When TreeList renders a visible header, that generated header id should keep naming the tree, so assistive tech hears the same name the user sees. An external aria-labelledby now only applies on the headerless path, and a caller aria-label is ignored when a header names the tree. Matches the precedence meta#5288 applies to List.
|
Thanks, @cixzhang - you're right that the header should keep naming the tree when it's visible. Applied the same precedence as #5288. When a visible |
cixzhang
left a comment
There was a problem hiding this comment.
Thanks for turning this around so fast — the header names the tree now, and the headerless paths still name it. Checked the accessible names in Chromium.
[Reviewed by Robohands]
Layout, MetadataList, NavHeadingMenuItem, RadioList, TimeInput, and TopNavMegaMenuItem declared extends BaseProps but destructured a closed set of props with no rest spread, so aria-*, id, data-*, and event handlers type-checked and silently never reached the DOM. Forward the rest object to the element each ref targets, composing consumer handlers in front of component-owned ones with composeEventHandlers (RadioList onFocus; TimeInput onFocus/onBlur/onKeyDown). Same class and same fix shape as the meta#5254 batches (meta#5288, meta#5493, meta#5563); these six were not in that issue's tarball-derived list. PowerSearch shares the shape and is deliberately left out - its forwarding target is an API decision.
Layout, MetadataList, NavHeadingMenuItem, RadioList, TimeInput, and TopNavMegaMenuItem declared extends BaseProps but destructured a closed set of props with no rest spread, so aria-*, id, data-*, and event handlers type-checked and silently never reached the DOM. Forward the rest object to the element each ref targets, composing consumer handlers in front of component-owned ones with composeEventHandlers (RadioList onFocus; TimeInput onFocus/onBlur/onKeyDown). Same class and same fix shape as the meta#5254 batches (meta#5288, meta#5493, meta#5563); these six were not in that issue's tarball-derived list. PowerSearch shares the shape and is deliberately left out - its forwarding target is an API decision.
Layout, MetadataList, NavHeadingMenuItem, RadioList, TimeInput, and TopNavMegaMenuItem declared extends BaseProps but destructured a closed set of props with no rest spread, so aria-*, id, data-*, and event handlers type-checked and silently never reached the DOM. Forward the rest object to the element each ref targets, composing consumer handlers in front of component-owned ones with composeEventHandlers (RadioList onFocus; TimeInput onFocus/onBlur/onKeyDown). Same class and same fix shape as the meta#5254 batches (meta#5288, meta#5493, meta#5563); these six were not in that issue's tarball-derived list. PowerSearch shares the shape and is deliberately left out - its forwarding target is an API decision.
Layout, MetadataList, NavHeadingMenuItem, RadioList, TimeInput, and TopNavMegaMenuItem declared extends BaseProps but destructured a closed set of props with no rest spread, so aria-*, id, data-*, and event handlers type-checked and silently never reached the DOM. Forward the rest object to the element that owns each component's contract, spread first so owned attributes win. Where the component owns the same event, handlers compose component-first with composeEventHandlers so owned behavior (focus normalization, arrow stepping, blur reconciliation) is uncancellable (RadioList onFocus; TimeInput onFocus/onBlur/onKeyDown on both its typed and native-picker paths). A caller id is honored via id ?? generatedId per the Selector precedent, and caller aria-labelledby and aria-describedby compose additively with the owned ids. Same class and same fix shape as the meta#5254 batches (meta#5288, meta#5493, meta#5563); these six were not in that issue's tarball-derived list. PowerSearch and MultiSelector share the shape and are deliberately left out - their forwarding is an API decision and a Selector-precedent follow-up. Co-Authored-By: Claude Fable 5 <[email protected]>
Layout, MetadataList, NavHeadingMenuItem, RadioList, TimeInput, and TopNavMegaMenuItem declared extends BaseProps but destructured a closed set of props with no rest spread, so aria-*, id, data-*, and event handlers type-checked and silently never reached the DOM. Forward the rest object to the element that owns each component's contract, spread first so owned attributes win. Where the component owns the same event, handlers compose component-first with composeEventHandlers so owned behavior (focus normalization, arrow stepping, blur reconciliation) is uncancellable (RadioList onFocus; TimeInput onFocus/onBlur/onKeyDown on both its typed and native-picker paths). A caller id is honored via id ?? generatedId per the Selector precedent, and caller aria-labelledby and aria-describedby compose additively with the owned ids. Same class and same fix shape as the meta#5254 batches (meta#5288, meta#5493, meta#5563); these six were not in that issue's tarball-derived list. PowerSearch and MultiSelector share the shape and are deliberately left out - their forwarding is an API decision and a Selector-precedent follow-up. Co-Authored-By: Claude Fable 5 <[email protected]>
Layout, MetadataList, NavHeadingMenuItem, RadioList, TimeInput, and TopNavMegaMenuItem declared extends BaseProps but destructured a closed set of props with no rest spread, so aria-*, id, data-*, and event handlers type-checked and silently never reached the DOM. Forward the rest object to the element that owns each component's contract, spread first so owned attributes win. Where the component owns the same event, handlers compose component-first with composeEventHandlers so owned behavior (focus normalization, arrow stepping, blur reconciliation) is uncancellable (RadioList onFocus; TimeInput onFocus/onBlur/onKeyDown on both its typed and native-picker paths). A caller id is honored via id ?? generatedId per the Selector precedent, and caller aria-labelledby and aria-describedby compose additively with the owned ids. Same class and same fix shape as the meta#5254 batches (meta#5288, meta#5493, meta#5563); these six were not in that issue's tarball-derived list. PowerSearch and MultiSelector share the shape and are deliberately left out - their forwarding is an API decision and a Selector-precedent follow-up. Co-Authored-By: Claude Fable 5 <[email protected]>
Layout, MetadataList, NavHeadingMenuItem, RadioList, TimeInput, and TopNavMegaMenuItem declared extends BaseProps but destructured a closed set of props with no rest spread, so aria-*, id, data-*, and event handlers type-checked and silently never reached the DOM. Forward the rest object to the element that owns each component's contract, spread first so owned attributes win. Where the component owns the same event, handlers compose component-first with composeEventHandlers so owned behavior (focus normalization, arrow stepping, blur reconciliation) is uncancellable (RadioList onFocus; TimeInput onFocus/onBlur/onKeyDown on both its typed and native-picker paths). A caller id is honored via id ?? generatedId per the Selector precedent, and caller aria-labelledby and aria-describedby compose additively with the owned ids. Same class and same fix shape as the meta#5254 batches (meta#5288, meta#5493, meta#5563); these six were not in that issue's tarball-derived list. PowerSearch and MultiSelector share the shape and are deliberately left out - their forwarding is an API decision and a Selector-precedent follow-up. Co-Authored-By: Claude Fable 5 <[email protected]>


Closes #5476
Problem
TreeListPropsextendsBaseProps, whose header states it keepsaria-*,role,tabIndex,idand event handlers.TreeListdestructures a fixed set of props with no rest spread, so everythingBasePropspromises is dropped and never reaches the DOM.The accessibility cost is the sharp one. The tree's only naming path is
aria-labelledby, wired to theheaderprop. A tree without a visible header cannot be named at all: a screen reader announces an unnamed tree and nothing says which tree it is.Change
Add
...restPropstoTreeListand spread it onto the root element, matching the existingListItem/Kbdpattern.aria-*,role,tabIndex,idand event handlers now forward to the DOM asBasePropspromises.aria-labelandaria-labelledbyare pulled out of the rest and routed onto the<ul role="tree">itself, so<TreeList aria-label="File tree">names the tree. A consumer-suppliedaria-labelledbywins over the internal header association, and the contractrole="tree"is written after the rest spread so a consumer cannot displace it.Test plan
packages/core/src/TreeList/TreeList.test.tsx- regression tests assertingaria-labelreaches the<ul role="tree">andidreaches the root element.pnpm vitest run packages/core/src/TreeList/TreeList.test.tsx- 78 passing.pnpm vitest run packages/core/src/List/List.test.tsx- 53 passing (unchanged).npx eslinton changed files - clean.npx prettier --checkon changed files - clean.