Skip to content

fix(TreeList): forward BaseProps attributes to the tree element (#5476) - #5493

Merged
cixzhang merged 2 commits into
meta:mainfrom
gonzoblasco:fix/list-treelist-baseprops-upstream
Aug 26, 2026
Merged

cixzhang merged 2 commits into
meta:mainfrom
gonzoblasco:fix/list-treelist-baseprops-upstream

Conversation

@gonzoblasco

@gonzoblasco gonzoblasco commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Closes #5476

Problem

TreeListProps extends BaseProps, whose header states it keeps aria-*, role, tabIndex, id and event handlers. TreeList destructures a fixed set of props with no rest spread, so everything BaseProps promises is dropped and never reaches the DOM.

render(<TreeList items={items} aria-label="File tree" />);

// <div class="astryx-tree-list ...">
//   <ul role="tree">
// aria-label -> null

The accessibility cost is the sharp one. The tree's only naming path is aria-labelledby, wired to the header prop. 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 ...restProps to TreeList and spread it onto the root element, matching the existing ListItem / Kbd pattern. aria-*, role, tabIndex, id and event handlers now forward to the DOM as BaseProps promises.

aria-label and aria-labelledby are pulled out of the rest and routed 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.

Test plan

  • packages/core/src/TreeList/TreeList.test.tsx - regression tests asserting aria-label reaches the <ul role="tree"> and id reaches 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 eslint on changed files - clean.
  • npx prettier --check on changed files - clean.

@vercel

vercel Bot commented Aug 25, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
astryx Error Error Aug 26, 2026 5:39pm

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Aug 25, 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 Aug 25, 2026
@github-actions

github-actions Bot commented Aug 25, 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.

Modified Components

TreeList (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 793 -
Complexity N/A Very High (81) -

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.8KB 1.2KB

Accessibility Audit

Status: No accessibility violations detected.

Visual Regression

Status: 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 cixzhang 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.

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:

accessible names

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."

role clobbered

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.
@gonzoblasco
gonzoblasco force-pushed the fix/list-treelist-baseprops-upstream branch from 94e8ee7 to eb0d3e5 Compare August 26, 2026 16:01
@gonzoblasco gonzoblasco changed the title fix(List): forward BaseProps attributes to the list element (#5476) fix(TreeList): forward BaseProps attributes to the tree element (#5476) Aug 26, 2026
@gonzoblasco

gonzoblasco commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor Author

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.

aria-label/aria-labelledby are now pulled out of the rest and routed 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 it is only written when the header exists, so it no longer erases a label a consumer pointed at their own heading. The test now asserts on getByRole('tree') instead of the wrapper div.

The contract role="tree" is written after the rest spread, so a consumer can no longer displace it.

Added a changeset. The List half is left to #5288.

@gonzoblasco
gonzoblasco requested a review from cixzhang August 26, 2026 16:19
github-actions Bot added a commit that referenced this pull request Aug 26, 2026

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

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

gonzoblasco commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor Author

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 header is rendered, the tree now names itself via the generated header id, so AT hears the same name the user sees. A caller aria-labelledby (or aria-label) only applies on the headerless path. Added tests covering both paths.

@github-actions
github-actions Bot requested a review from cixzhang August 26, 2026 17:39
github-actions Bot added a commit that referenced this pull request Aug 26, 2026

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

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]

@cixzhang
cixzhang enabled auto-merge (squash) August 26, 2026 18:23
@github-actions github-actions Bot removed the needs:code-review High-risk change (new package/component/API) — needs human code review before merge label Aug 26, 2026
@cixzhang
cixzhang merged commit b47ad01 into meta:main Aug 26, 2026
22 of 23 checks passed
@gonzoblasco
gonzoblasco deleted the fix/list-treelist-baseprops-upstream branch August 26, 2026 18:42
harjothkhara added a commit to harjothkhara/astryx that referenced this pull request Sep 3, 2026
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.
harjothkhara added a commit to harjothkhara/astryx that referenced this pull request Sep 3, 2026
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.
harjothkhara added a commit to harjothkhara/astryx that referenced this pull request Sep 3, 2026
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.
harjothkhara added a commit to harjothkhara/astryx that referenced this pull request Sep 3, 2026
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]>
harjothkhara added a commit to harjothkhara/astryx that referenced this pull request Sep 3, 2026
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]>
harjothkhara added a commit to harjothkhara/astryx that referenced this pull request Sep 3, 2026
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]>
harjothkhara added a commit to harjothkhara/astryx that referenced this pull request Sep 3, 2026
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]>

This branch had an error being deployed

1 failed deployment
Preview — 39bccc84 Deployed Aug 26, 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.

[Bug] List and TreeList drop every BaseProps attribute, so aria-label never reaches the DOM

2 participants