Skip to content

feat(Table): treegrid semantics and row-focus keyboard model for the tree plugin - #4690

Open
AKnassa wants to merge 9 commits into
meta:mainfrom
AKnassa:rocky/issue-4681-aria-conditional-attr
Open

AKnassa wants to merge 9 commits into
meta:mainfrom
AKnassa:rocky/issue-4681-aria-conditional-attr

Conversation

@AKnassa

@AKnassa AKnassa commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Part of #4681 (weekly a11y scan). Clears the 8 aria-conditional-attr baseline entries for TableTree. The 3 TableGroupedRows entries move to their own PR, #5612, as agreed in review.

What changed since the last round

Review asked for a treegrid instead of stripping the row ARIA, and the ruling set v1 scope to row focus. This round builds that:

  • Role. With any expandable row, useTableTreeData names the <table> role="treegrid" via transformTable. Flat data keeps the native table (no role, no row ARIA, no tab stop): the migration guarantee holds.
  • Row ARIA. Rows keep aria-level (1-based) and aria-expanded (parents only), and gain aria-posinset / aria-setsize from the sibling group as flattened by useTableTreeState (after sortSiblings). TableTreeRowMeta carries them as optional posInSet / setSize, so a hand-built config still typechecks.
  • Keyboard, row focus. Composed from useTreeFocus (the shared tree primitive) pointed at the rows through its itemSelector: one roving tab stop across the visible rows; ArrowUp/ArrowDown move between rows; ArrowRight expands a collapsed row or enters its first child; ArrowLeft collapses an expanded row or moves to the parent; Home/End; Enter/Space toggle an expandable row; RTL flips the horizontal arrows (the hook already does). Focus survives the expand/collapse re-render because rows are keyed by id. Typeahead is off: not part of the treegrid pattern, and printable keys must reach a text field inside a cell.
  • Interactive descendants stay reachable. The tree keys apply only when a row itself owns focus: a key pressed on the chevron, a selection checkbox, a sort header, or a text field keeps its native meaning. Those controls also stay in the Tab order (the row is one extra Tab stop ahead of them). That is the v1 contract the ruling describes; an entry mode or cell navigation is a separate decision.
  • Focus ring. Rows draw the shared focusOutlineStyles.focusVisible ring, inset so it is not clipped by neighbouring rows.
  • Docs name the v1 limitation (useTableTreeData.doc.mjs description, usage best practices, hasRowClickExpansion), and the Default story's JSDoc summarises the keys.

Two supporting changes outside the plugin:

  • TableRenderProps.ref: a plugin can now attach a ref to the <table>; BaseTable merges it with the consumer's ref (memoised, so callback refs are not re-attached every render). Mirrors BodyRowRenderProps.ref / ScrollWrapperRenderProps.htmlProps.ref.
  • useTreeFocus resolves the focused item with closest(itemSelector) instead of a hardcoded [role="treeitem"]. Without this, a custom itemSelector listed the rows but ArrowDown from a focused row went back to the first row (the focused item resolved to null). Default behaviour is unchanged; TreeList is unaffected.

Why useGridFocus is not in the composition

useGridFocus is cell geometry (columns, a cell selector, Ctrl+Home/End across cells). With row focus there are no cells to navigate, so v1 composes on useTreeFocus alone. When cell navigation is decided, that is where the grid hook comes in.

Judgment calls, stated plainly

  • Enter/Space toggle any expandable row (the primitive's default), not only when hasRowClickExpansion is set; hasRowClickExpansion stays a pointer-only convenience.
  • Space on a focused row toggles expansion, not selection. In the selection composition, selection stays on the checkbox (Tab-reachable). Flagging in case Space should be reserved.
  • Changeset is patch (the repo rule: only [breaking] bumps minor while 0.x), but the entry spells out what consumers will notice: the rows become a Tab stop, and getByRole('table') becomes treegrid for tree tables.

Verification

  • Tests first (red), then the implementation: 18 new tests (treegrid role, posinset/setsize, roving tabindex, every key, the descendant guard, RTL, no typeahead, ref composition), all green; 941/941 across Table, hooks, TreeList.
  • core typecheck, core typecheck:docs, cli typecheck:strict, storybook typecheck clean; eslint clean on the changed files (one pre-existing warning on main's BaseTable.tsx:489).
  • axe audit with --fail-on-new, TableTree + TableGroupedRows: 0 new; 0 issues on all 9 TableTree stories; TableGroupedRows shows only its 3 baselined entries (the split PR). The audit also reports TableGroupedRows::Default::color-contrast and ::Initially Collapsed::color-contrast as resolved; left for a contrast round.

Checked in Chrome on the built Storybook (Default story): the <tr> paints the inset ring on keyboard focus, ArrowRight expands in place and then enters the first child, ArrowLeft returns to the parent, Tab from the row reaches its chevron, and arrows on the chevron do nothing. Observation: the scroll wrapper is already a Tab stop (pre-existing), so a tree table reads wrapper, then row, then in-cell controls; whether the wrapper stop should yield once rows are focusable is a separate question.

Follow-ups this PR does not claim: cell navigation, an entry mode for in-cell controls.

axe aria-conditional-attr (serious): aria-expanded and aria-level are
valid on rows only inside a treegrid, and Astryx Table is a native
table. The tree and groupedRows plugins set them on every <tr>,
firing on all 10 baselined TableTree/TableGroupedRows stories plus
the never-baselined Row Click Expansion story.

Rows now carry no tree ARIA; expansion state stays announced by the
chevron buttons (rowExpansion-plugin pattern). The per-row
ref/subscription machinery existed solely to apply row ARIA and is
removed with it (-77 lines). Trade-off recorded in the changeset:
depth is currently visual-only via indentation; a programmatic depth
cue for AT is a tracked follow-up. Baseline: -10 entries.

Verified: 474/474 Table tests, core typecheck, eslint clean, axe
audit 0 violations across all 12 stories with --fail-on-new.

Part of meta#4681.
@vercel

vercel Bot commented Aug 3, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 7, 2026 1:58am UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Aug 3, 2026
@AKnassa
AKnassa marked this pull request as ready for review August 4, 2026 01:48
@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 4, 2026
@github-actions

github-actions Bot commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR

🧪 Sandbox Preview

View Sandbox for this PR

No new or modified components detected.

Bundle Size Summary

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

Accessibility Audit

Status: No accessibility violations detected.

Visual Regression

Status: No visual change across 420 compared shot(s).


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

github-actions Bot added a commit that referenced this pull request Aug 4, 2026

describe('useTableTreeData — row ARIA', () => {
it('sets 1-based aria-level on every body row', () => {
it('never sets aria-level on rows — the indent conveys hierarchy (axe aria-conditional-attr: rows outside a treegrid)', () => {

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.

Hmm well this seems wrong. If we include tree data the table should probably be a treegrid.

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

I think the fix might be to apply the treegrid row when including tree data. We will likely need to make a version of useTreeGridFocus to achieve the right behaviors. It's quite a bit though. Let me know if you wanna do it!

@AKnassa

AKnassa commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

Yes, happy to take it on.

Agreed treegrid is the right semantics. The row ARIA removed here was already treegrid shaped (1-based aria-level, aria-expanded on parents only), the container was the invalid part. Rough plan:

  • role="treegrid" via transformTable, applied only when expandable rows exist so flat data keeps the plain table.
  • Restore aria-level/aria-expanded on rows and add aria-posinset/aria-setsize, computed from the flattened visible list.
  • New useTreeGridFocus: roving tabindex with row focus, Up/Down across visible rows, Right expands, Left collapses or jumps to parent, Home/End, Enter toggles where row-click expansion is on, focus preserved across expand/collapse re-renders. Role and keyboard ship together, a treegrid without arrow support would regress below the plain table.

Two questions before I start:

  1. Do you have a reference useTreeGridFocus I should mirror? Related: is row focus enough for v1, or do you want cell navigation too? Either way the table becomes one tab stop, so in-cell widgets (sort headers, chevrons, selection checkboxes) stop being individually tabbable.
  2. groupedRows is not tree data, and its change here just leaves the expanded state on the group toggle button. OK to split it into its own PR and keep this branch for the treegrid work?

@cixzhang

Copy link
Copy Markdown
Contributor

Sorry for the wait on this.

On a reference: useTreeFocus and useGridFocus are both public hooks with docs and tests — packages/core/src/hooks/useTreeFocus.ts and useGridFocus.ts. A treegrid version is those two composed, so they're the ones to mirror.

Row focus versus cell navigation I don't want to answer off the cuff. You've named the cost exactly right — the table becomes one tab stop and sort headers, chevrons and selection checkboxes stop being individually tabbable — and that's a call for a maintainer rather than a review. It's queued.

Yes to splitting groupedRows out. It isn't tree data, moving the expanded state onto the chevron button stands on its own, and it clears three axe entries; no reason for it to wait behind the treegrid work.

If you'd rather talk it through with someone, we're in Discord.

[Reviewed by Robohands]

@gonzoblasco

Copy link
Copy Markdown
Contributor

On the row-focus vs cell-navigation question that's queued with maintainers - here's the AT angle that might help the decision, since it's the part that's easy to miss when reasoning about tab stops alone.

The two options aren't just "how many tab stops" - they map to different ARIA contracts, and the in-cell widgets decide which is viable:

Row focus (one tab stop per row) is closer to a list/tree semantics than a grid.
With roving tabindex at the row level, the row is the focusable unit and sort headers / chevrons / selection checkboxes inside it are no longer individually in the tab order. That means those widgets need a second mechanism to be reachable at all - typically Enter/F2 to "enter" the row, then Tab within it, then Escape to leave (the composite-widget entry pattern from APG). Without that, you've traded individually-tabbable controls for a row that swallows them - which is the exact cost @AKnassa named, but the fix isn't automatic: it requires the composite entry model, not just moving the tab stop.

Cell navigation (roving per-cell) matches the APG grid pattern directly.
In a treegrid, each cell is focusable with roving tabindex, and arrow keys move between cells; widgets inside a cell stay reachable because the cell (not the row) is the focused unit, and Tab moves into the widget from the focused cell. This is the pattern the APG documents for grids, and it's what aria-rowindex/aria-colindex semantics assume. The cost is the opposite one: more moving parts in the keyboard model, and a heavier interaction for users who just want to tab through.

So the deciding question isn't "row vs cell" in the abstract - it's: do the tree rows carry in-cell interactive widgets (sort headers, chevrons, selection) as part of the treegrid contract? If yes, cell navigation (or a row model with an explicit composite-entry mechanism) is the only way those stay reachable. If the treegrid v1 rows are plain data cells with the expander as the sole interaction, row focus is simpler and defensible - and the in-cell widgets can be explicitly out of scope for v1, documented, and revisited when they're added.

Either way, the keyboard model and the ARIA indexes should match whatever is chosen - a row-focus model emitting per-cell aria-colindex would contradict itself, and a cell model with row-level roving would too.

@cixzhang

Copy link
Copy Markdown
Contributor

Thanks for waiting. The decision window has closed: row focus is the v1 scope, with the docs naming that full cell navigation is outside v1. Existing interactive descendants must remain reachable; combinations that need cell navigation stay outside the supported v1 contract.

You can proceed by composing the existing tree and grid focus primitives. Decision record

[Reviewed by Robohands]

@gonzoblasco

Copy link
Copy Markdown
Contributor

On the v1 row-focus scope and the "existing interactive descendants must remain reachable" requirement - one concrete way to satisfy that without pulling in the full composite-entry pattern:

In a row-focus model, the row is the single tab stop and the in-cell widgets (sort headers, chevrons, selection checkboxes) drop out of the tab order. The APG composite-widget entry pattern (Enter/F2 to enter the row, Tab within, Escape to leave) is the full solution, but it's heavy for a v1. A lighter option that keeps the widgets reachable: keep the row as the tab stop, and let the widgets inside remain reachable via the screen reader's virtual cursor / browse mode even though they're not in the sequential tab order. That's the key distinction: "reachable" for AT doesn't have to mean "in the tab order" - browse mode can still get to them.

The trap to avoid is the middle ground: making the row focusable but leaving the widgets also in the tab order, which creates two competing tab stops per row and a confusing keyboard model. Either the row is the single stop (widgets reachable via browse mode / composite entry), or the widgets stay individually tabbable (which is the cell-nav model, out of v1). The one thing that doesn't work is both.

So for v1: row as the single tab stop, widgets reachable via browse mode, and document that composite entry (Enter/F2) is the follow-up if keyboard-only users need direct widget access. That keeps the v1 contract clean and the widgets reachable, without the full composite-entry machinery.

Resolved toward main's tree plugin: the review asks for a treegrid with
restored row ARIA, so the row-ARIA removal this branch carried is dropped
here rather than re-applied. The groupedRows half moves to its own PR
(agreed in review), so those files return to main's version too. Only
the 8 TableTree aria-conditional-attr baseline entries stay removed.
…ugin

Review asked for a treegrid rather than stripping the row ARIA. When any
row is expandable the tree plugin now names the <table> role="treegrid"
(transformTable) and keeps aria-level / aria-expanded on the rows, adding
aria-posinset / aria-setsize from the sibling group as flattened by
useTableTreeState. Rows get the row-focus keyboard model from useTreeFocus
(one roving tab stop; ArrowUp/Down, ArrowRight expand-or-enter,
ArrowLeft collapse-or-parent, Home/End, Enter/Space toggle), scoped to the
row that owns focus so in-cell controls keep their own keys and stay in
the Tab order. v1 is row focus only per the maintainer ruling; the docs
say so. Flat data is untouched.

Supporting changes: TableRenderProps.ref (merged with the consumer's ref
in BaseTable) so a plugin can reach the <table>; useTreeFocus resolves
the focused item through itemSelector instead of a hardcoded
[role="treeitem"], which is what lets the table compose it.

Baseline: the 8 TableTree aria-conditional-attr entries stay removed
(axe audit with --fail-on-new: 0 issues across all 9 TableTree stories).
groupedRows is split into its own PR as agreed.

Part of meta#4681
@github-actions
github-actions Bot requested a review from cixzhang August 27, 2026 19:35
@github-actions github-actions Bot added the needs:design-review Affects visuals — Design should review label Aug 27, 2026
@AKnassa

AKnassa commented Sep 26, 2026

Copy link
Copy Markdown
Contributor Author

Sorry for the slow reply, @rubyycheung and @humbertovirtudes. I'm continuing with this. I've pushed the fixes and merged main. The merge was clean and brings in #6410, so the scroll region is now a Tab stop only while the table overflows sideways.

  • Caller props on <Table>: a caller's <table> handler now runs before the plugin's instead of replacing it, and preventDefault() in it skips the plugin's handler. A plugin's role wins over the caller's, with a dev warning. A wrapper that forwards an unset handler (onKeyDown={props.onKeyDown}) no longer removes navigation. Tests go through <Table>. c01c715, 7448da8
  • Roving stop follows focus: a row focused by a click or by code becomes the Tab stop. The fix is in useTreeFocus, so TreeList gets it too. c01c715
  • Chevron focus ring: the row expander and the header expand-all toggle now use the shared focus-visible ring. c01c715
  • Tab order: the docs, changeset and story now give one order: scroll region (only while overflowing), then header controls, then in-cell controls and the one active row in DOM order, then out. A Tab-walk test pins this order. c01c715
  • Arrow keys: ArrowRight on an expanded row and ArrowLeft on a collapsed or leaf row now keep focus on the row, in LTR and RTL. Per the v1 ruling, focus is on rows only, so there is no cell for ArrowRight to move into. It holds instead of moving into a cell. In-cell controls stay in the Tab order because the ruling requires them to remain reachable. c01c715

Still to do on my side: a before/after screenshot of the chevron ring and a browser recording of the keyboard model. Could you confirm that holding focus on ArrowRight is acceptable for v1?

@astracat-bot astracat-bot Bot 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 the follow-up round — the treegrid repair is now dependable for keyboard users, and approval is recommended from this review.

The issues raised on the previous revision are addressed:

  • A caller's onKeyDown or onFocus on Table now composes with the plugin's handlers (caller first, preventDefault() opts out), a wrapper forwarding an unset handler no longer removes navigation, and a plugin's treegrid role wins over a caller's role with a development warning — each covered by tests through Table.
  • The roving tab stop now follows a row focused by click or by code, while focusing an in-cell control leaves the stop in place; the fix in the shared focus hook also benefits TreeList.
  • The row expander and the header expand-all toggle draw the shared focus ring, like the row.
  • The intended Tab order is stated in the docs, changeset, and story and pinned by a Tab-walk test, and ArrowRight/ArrowLeft now hold focus where the treegrid pattern would enter a cell or do nothing, instead of jumping to a child or parent row.

Two things remain for the human reviewers and for you, as you noted: confirmation that holding focus on ArrowRight for an expanded row is acceptable for v1, and the before/after chevron screenshot and keyboard recording you listed as still to do.

[Automated review]

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

Reviewed exact head 7448da82 and the surrounding tree focus, Table, and accessibility implementation. Requesting changes for two functional gaps.

  1. packages/core/src/Table/plugins/tree/useTableTreeData.tsx:711-726 keeps focus on an expanded row, and packages/core/src/hooks/useTreeFocus.ts:478-497 makes ArrowRight a no-op on leaves. The public docs say this follows the APG treegrid pattern, where ArrowRight from an expanded or leaf row enters the first cell. Either implement cell entry/navigation or document and specify the row-only model instead of claiming APG parity.

  2. The new focus and keyboard behaviour is covered only through jsdom events in useTableTreeData.test.tsx:1182-1419. This cannot prove native <tr> focus, sequential Tab behaviour, RTL arrow routing, or visible focus in a browser. Please add browser coverage for row entry/exit, click focus, Up/Down, LTR/RTL Left/Right, in-cell controls, and the focus indicator.

Cross-PR conflict: this patch conflicts with #5995 in useTableTreeData.tsx. Rebase after #5995 and preserve its shared row-scoped interactive-target and text-selection guards. #6221 also overlaps the Table root/ref area, so retain both its scroll ownership and this PR's root-prop composition.

@astracat-bot astracat-bot Bot 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 carrying this through several rounds: the row-focus treegrid behaves as documented in Chromium, and flat tables are untouched. Approval now needs a maintainer to provide or identify the governing spec for the tree plugin's treegrid contract, which no current record covers: the role and row attributes, the row-focus keys including ArrowRight holding focus on expanded and leaf rows, in-cell controls staying in the Tab order, and the new TableRenderProps.ref seam. Independently of that decision, please:

  • Rebase onto main, which now conflicts in useTableTreeData.tsx, Table.doc.mjs and TreeList.test.tsx, keeping main's shared row-click guards and the useTreeFocusInternal split.
  • Describe the keyboard model as a row-focus subset of the APG treegrid pattern and name its divergences instead of saying it follows the pattern, or implement cell entry.
  • Add one sentence to the description classifying the change under the AST-009 assistive-technology triggers.

The engineering owners with open change requests will also need to re-review.

[Automated review]

@kentonquatman kentonquatman 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 looking at this @AKnassa! I'm seeing some visual regressions with the focus ring. Could we fix this before merging? I also wanted to confirm if the change in content alignment was intentional.

Before After
Image Image

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

Requesting changes on 7448da8209900385bb3308d2dc0ec03431f18c25. Consumer/root handler and ref composition, row-scoped keyboard handling, roving-stop updates and flat-table preservation are credited.

  1. MAJOR - public wording overstates APG parity. useTableTreeData.doc.mjs:9-10 and the release note claim the APG treegrid pattern, but inline-end arrow on an expanded/leaf row holds focus rather than entering the first cell, and descendant controls remain in ordinary page Tab order. Describe the exact owner-admitted row-focus subset and both divergences, or implement the owner-selected cell-entry model. Reconcile the PR body's stale child/parent-arrow observations with the actual source.

  2. MAJOR - native focus/visual proof remains incomplete. useTableTreeData.test.tsx:1182-1419 uses synthetic focus/keys/Tab and class-based ring checks. These do not prove real <tr> focus, reverse Tab, LTR/RTL focus paint or clipping. Provide inspectable head-bound browser keyboard/visual evidence, including nested controls, selection/sort, fit/overflow and active-row removal. The latest visual-regression review also remains unresolved; I have not independently reproduced or inspected those images.

Owner/integration hold: maintainers need to record the precise tree-module and shared Table ref/event contract in the current canonical owners. This is not a request for an external contributor to author a broad new spec. Rebase while preserving the newer row-scoped contenteditable/text-selection guards and internal tree-focus split, rather than taking stale complete files. The primary feature is not wholly superseded.

AI-assisted exact-head source review. No fresh browser/AT result is claimed; add real AT only for AT-dependent announcement/browse-mode claims, not merely static semantics or browser focus.

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

Requesting changes on exact head 7448da8209900385bb3308d2dc0ec03431f18c25 for the Table-related delta and its direct dependencies. This is not a rejection of unrelated work in the PR.

  1. [MAJOR] packages/core/src/Table/useTableTreeData.doc.mjs:10

The consumer description and release note still claim APG treegrid parity for a row-only subset.

Failure case: Inline-end on an expanded row is intercepted at useTableTreeData.tsx:715-724; inline-end on a leaf reaches useTreeFocus.ts:478-497 and holds focus. Neither enters a first cell. Descendant controls remain in ordinary page Tab order. The description says the keyboard follows the APG treegrid pattern despite conceding the missing cell entry later, and the PR body's child/parent-arrow observations are stale at this head.

Requested fix: Describe the precise row-focus subset and its two divergences consistently in normal/dense docs, release note and PR body. Retain the owner's row-focus v1 direction; do not require cell navigation merely to rescue an overstated claim. If a different keyboard contract is wanted, maintainers must decide it in the canonical owner.

  1. [MAJOR] packages/core/src/Table/plugins/tree/useTableTreeData.test.tsx:1182

The newly introduced native row-focus and visible-focus promises lack inspectable, head-bound focused browser regression evidence.

Failure case: The tests use jsdom focus, fireEvent keys and userEvent.tab, including a five-stop forward Tab walk. Ring tests compare compiled classes. They cannot establish native tr focus, reverse Tab, inherited RTL routing, clipping, or focus continuity after active-row removal. Broad successful axe/visual jobs and prose observations do not prove those transitions.

Requested fix: Provide the outstanding before/after ring evidence and keyboard recording, and focused real-browser regression coverage through the committed TableTree fixture for entry/exit, reverse Tab, click/programmatic focus, directional keys, nested selection/sort controls, fit/overflow and focused-row removal. Reuse canonical visual coverage for pixels; do not introduce a duplicate visual harness.

Validation boundary: these findings are grounded in the exact implementation and relevant tests. Isolated source/geometry probes are not fresh mounted React, browser, clipboard, screen-reader or native-device certification. Retain the applicable focused tests and head-bound evidence when updating the PR.

Resolve only the surviving narrow authority/integration questions in the existing canonical owner; do not create a parallel public API or an unrelated record to bypass them.

Conflicts kept both sides: React imports and isRenderable in BaseTable.tsx;
the plugins description in Table.doc.mjs; the @input header and the
row-click guard imports in useTableTreeData.tsx; test imports in
TreeList.test.tsx and useTreeFocus.test.tsx; the typeahead wording in
useTreeFocus.doc.mjs.
Conflicts kept both sides: the getRowLabel and hasExpandableRows dense
prop descriptions in useTableTreeData.doc.mjs, and the TreeTable test
fixture's getRowLabel and tableProps props in useTableTreeData.test.tsx.
Answers the meta#4690 review (humbertovirtudes, 10-22 and 11-04).

A collapse or data change that removed the focused row dropped
focus to the page and reset the tab stop to the first row. Focus
(only if lost) and the stop now move to the nearest remaining
ancestor. For focus on a collapse, that is TreeList's AR2 rule.
Unlike TreeList, the stop moves even when focus is elsewhere.
Alt and Meta chords now pass through, so browser Back works on a
focused row.

Docs, dense docs and changeset now describe the keys the same way:
a row-focus subset of the APG treegrid pattern plus Enter/Space,
with its two divergences named. The story summarizes them.

New jsdom tests cover the dropped-row moves, the leaf and end-row
holds, Space, and the modifier chords. A new browser spec (22
tests per engine) and accessibility-tree spec (6 tests) run
through the committed TableTree stories. api-report.md gains the
PR's ref, posInSet and setSize rows.

@astracat-bot astracat-bot Bot 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 carrying this through another round: this head fixes the APG-parity wording, adds the browser proof reviewers asked for, keeps main's shared row-click guards, and leaves flat tables untouched.

Approval now needs an engineering owner to provide or identify the governing spec for the tree plugin's treegrid contract, which no current record covers: the existing useTableTreeData record contracts only expander names. What must be settled is the treegrid role and row ARIA, the row-focus keys (including ArrowRight and ArrowLeft holding focus), in-cell controls staying in the Tab order, focus moving to the nearest ancestor when a row is dropped, and the Table seams (TableRenderProps.ref, caller-first handler composition, plugin role precedence). An engineering owner records that decision by commenting /approve-spec <full head SHA> on this pull request; the author may do so if they are an engineering owner.

Independently of that decision, please:

  • Regression: merge main, which now conflicts in .github/a11y-baseline.json, keeping main's removals and dropping the eight TableTree entries.
  • Newly live check: update the description's keyboard bullet, Chrome check and test counts, which still say ArrowRight enters the first child and ArrowLeft returns to the parent while the code and its browser test hold focus.
  • Miss: give the chevron and the header expand-all toggle room for the shared focus ring, which now reaches 1px into the row label (useTableTreeData.tsx lines 433 and 481).
  • Reduce scope, which now exceeds about 2,000 authored lines: land the useTreeFocus focus-follow fix and the Table root-prop composition with TableRenderProps.ref as their own pull requests first (each already has its own changeset); the dropped-row focus handoff is the next natural split.

The engineering and design owners with open change requests will also need to re-review.

[Automated review]

{...stylex.props(treeStyles.expanderButton)}
{...stylex.props(
treeStyles.expanderButton,
focusOutlineStyles.focusVisible,

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.

The shared ring here is 2px at a 3px offset, so it reaches 5px past a button that sits 4px from its label. In Chromium its outer edge lands at x=57 while the row label starts at x=56, so the ring runs into the first letter (the browser ring on main left a 3px gap). The same applies to the header toggle at line 481. Giving the expander at least 1px more inline clearance before the label, or an offset that fits the 4px gap, would fix both.

[ref, pluginTableRef],
);

// The caller's <table> props compose with the plugins' instead of silently

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.

Non-blocking (INV29 source comments): this comment restates the next line and the JSDoc of resolveTableHtmlProps. It can go.

[idToItem, store],
);

// The row keys come from the shared tree primitive, pointed at this

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.

Non-blocking (INV29 source comments): this comment covers five topics and opens by narrating the call. Keeping only the reasons reads better, for example: "A per-instance marker keeps a nested table's rows out of this row set. Type-ahead is off: printable keys must reach a text field in a cell."

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

Recheck at fccff4f (unchanged since 7 Nov): REVISE. Root handler/ref composition and roving-stop synchronisation are resolved, and the browser coverage you added (native row focus, forward/reverse Tab, LTR/RTL keys, nested controls, sorting, overflow, removed rows) is good. No CI has run on this head.

Blocking

  1. Authority. docs/specs/components/Table/plugins/tree/useTableTreeData.spec.md:49 contracts only expander naming and explicitly excludes the full plugin, keyboard and focus. The treegrid role/row ARIA, row-focus model, descendant Tab order, dropped-row handoff, TableRenderProps.ref and root-event/role precedence aren't admitted. An engineering owner needs to extend the Table/module records (or identify current clauses) for every public API and behavioural delta first.
  2. Conflicts with main. Rebase, keeping main's useIsomorphicLayoutEffect latest-value ref sync (this head still writes refs during render at useTableTreeState.tsx:140) and its baseline removals, then reapply posInSet/setSize.

Major
3. #8873 has merged and owns the row-expander and expand-all shared-ring change. Drop the duplicate ring delta here when you rebase.
4. The ring crosses into the label: the toggle-to-label gap is 4px, but the shared outline reaches 5px past the 24px button (useTableTreeData.tsx:317). Add token-based clearance of at least the ring reach, and a browser assertion that the ring doesn't cross the label's box.
5. Size: about 3.3k authored lines, including independently releasable root-prop/ref composition and shared useTreeFocus changes, each with its own changeset. Land those separately, then rebase this PR onto them.

The PR description is also stale on child/parent arrow movement and test counts.

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

Design looks good! Thanks @AKnassa!

@cixzhang

Copy link
Copy Markdown
Contributor

(Posted by Cindy's agent.) Hi @AKnassa, thanks for this PR. main has moved, and this branch now conflicts with it in 5 files (.github/a11y-baseline.json, packages/core/api-report.md, packages/core/src/Table/BaseTable.tsx, packages/core/src/Table/plugins/tree/useTableTreeData.tsx and one more). Could you merge or rebase onto current main? CodeBunny reviews again automatically after you push.

This branch was successfully deployed

1 active deployment
Preview — fccff4fa Deployed Nov 7, 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) needs:code-review High-risk change (new package/component/API) — needs human code review before merge needs:design-review Affects visuals — Design should review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants