Repository navigation
Description
Problem
We now have two overlapping tree/hierarchy plugins for Table:
useTableRowExpansion(feat(core): add useTableRowExpansion plugin #3441, merged) — inherited-columns tree: consumer passes flat data +getDepth, chevron on the first content column, a header expand-all toggle, and whole-row-click expansion.useTableTreeData+useTableTreeState(feat(table): tree data plugin — useTableTreeState + useTableTreeData #3789) — nested data, in-place cell decoration, external-store per-row subscriptions, imperative row ARIA, cycle guard, flat-data no-op, controlled + uncontrolled modes, token-based indent,sortSiblings.
useTableRowExpansion has no remaining detail-panel / arbitrary-content surface — that path was stripped earlier, so it is purely hierarchy. The two plugins are therefore genuinely redundant, not two different surfaces that happen to overlap.
Why converge on the tree plugin (not rowExpansion)
useTableTreeData is the stronger base to keep:
- Fine-grained re-render — a toggle re-renders only the affected cells via
useSyncExternalStore, not the whole body (useTableRowExpansionre-renders broadly). - Cycle guard — an ancestor-chain
Setin the flatten walk skips cyclic edges. This is exactly the fix useTableRowExpansion: add cycle guard to tree walks (stack overflow on cyclic data) #3971 wants foruseTableRowExpansion; converging resolves that bug class for free. - Row ARIA —
aria-level/aria-expandedapplied imperatively per<tr>, self-cleaning on disconnect. - Uncontrolled + controlled modes, token indent (
'sm' | 'md' | 'lg'), and a flat-data no-op so adopting it ahead of hierarchical data costs nothing.
The Q3 Table tracker (#3639) is explicitly trying to avoid API sprawl, so we land one tree plugin and retire the other.
What to fold from useTableRowExpansion into useTableTreeData
Two affordances useTableRowExpansion has that the tree plugin does not yet:
- Header expand-all toggle.
useTableRowExpansionrenders a header toggle button driven byisAllExpanded: boolean | 'indeterminate'+onToggleExpandAll.useTableTreeStatealready computes the state (expandAll/collapseAll) but there is no built-in header UI. Port the header affordance, wired to the tree state's all / none / indeterminate. - Whole-row-click expansion.
useTableRowExpansion'shasRowClickExpansiontoggles a row from a click anywhere on it, not just the chevron. Add the equivalent touseTableTreeData.
Both are additive and behind opt-in flags, so existing tree consumers are unaffected.
Migration + deprecation
- Document a migration path for existing
useTableRowExpansionconsumers:expandedKeys/onTogglemap touseTableTreeStatecontrolled mode;getDepth+ flat data map to constructing atreeConfigdirectly (the tree plugin already supports pre-flattened / server-driven trees this way). Ship a codemod if the consumer surface is wide enough. - Once the two affordances land and the migration path is documented, deprecate
useTableRowExpansion— soft-deprecate in docs + JSDoc first; removal is a later breaking change.
Fallback if we must keep both
If back-compat forces us to keep useTableRowExpansion as a distinct plugin, do not keep two independent tree walks. Extract the shared flatten / depth / expand-all / cycle-guard logic into one internal util both plugins consume, and at minimum port the cycle guard (#3971) so both are correct. Convergence is preferred; this is the floor.
Refs
- Lands: feat(table): tree data plugin — useTableTreeState + useTableTreeData #3789 (tree plugin, closes Table: tree data support (indentation + expand/collapse) as a useTableTreeData plugin #3346)
- Supersedes: feat(core): add useTableRowExpansion plugin #3441 (
useTableRowExpansion) - Resolved by convergence: useTableRowExpansion: add cycle guard to tree walks (stack overflow on cyclic data) #3971 (
useTableRowExpansioncycle guard) - Tracker: [Tracker] Table feature suite — Q3 plugin parity #3639
Activity
humbertovirtudes commentedon Jul 22, 2026
Implementation plan
Now that #3789 has merged,
useTableTreeData+useTableTreeStateis the surviving engine and the stronger base: it already has the cycle guard, controlled + uncontrolled modes, the flat-data no-op, per-rowuseSyncExternalStoresubscriptions, and imperative row ARIA. This is the concrete work to convergeuseTableRowExpansioninto it.The two feature gaps to fold in
Both are additive and behind opt-in flags, so existing tree consumers are unaffected.
useTableRowExpansionrenders a header toggle driven byisAllExpanded: boolean | 'indeterminate'+onToggleExpandAll.useTableTreeStatealready computes the underlying state (expandAll/collapseAllexist) but exposes no'indeterminate'value and no header UI. Add the all / none / indeterminate value touseTableTreeState's result, then render the header toggle button inuseTableTreeData.useTableRowExpansion'shasRowClickExpansiontoggles a row from a click anywhere on it, not just the chevron. Add the equivalent touseTableTreeData(a row-level click handler in its row-props path).The one real design decision: column model
This is where the two plugins genuinely diverge and a consumer will see a difference:
useTableRowExpansionprepends a synthetic 40px__expansioncolumn for the depth-0 chevron, then indents child-row chevrons inline in the first user column.useTableTreeDatauses no extra column: it decorates the tree column's cells in place (chevron + indent inline at every depth), with a configurabletreeColumnKey.The tree in-place model is cleaner (no phantom column), but any
useTableRowExpansionconsumer whose layout assumes the dedicated leading column will shift. Decision needed: adopt the tree in-place model as the single behavior (recommended), or add an opt-in "leading expander column" mode to the tree plugin for back-compat. Flagging for @cixzhang and @AKnassa.Config mapping (the migration surface)
useTableRowExpansionuseTableTreeData/useTableTreeStateequivalentexpandedKeys: Set+onToggle(key)+setExpandedKeysexpandedIds: ReadonlySet+onExpandedIdsChange(controlled), orinitialExpandedIds(uncontrolled)getDepthdata+childrenKey;useTableTreeStateflattens and derives depthgetChildrenchildrenKeygetRowKeyidKeygetIsItemExpandablegetIsExpandable(rename)isAllExpanded/onToggleExpandAllhasRowClickExpansionThe sharpest mismatch is id/key derivation:
useTableRowExpansionaccepts a standalonegetRowKey, while the tree plugin keys off the table'sidKey. Consumers passing a customgetRowKeyneed a documented migration path, or the tree plugin needs to accept an optional key override. Scope this carefully.Work breakdown (stacked PRs, after #4070 and #4073 merge)
'indeterminate'state touseTableTreeState's result and the header toggle UI inuseTableTreeData, behind a flag. Tests + story.hasRowClickExpansionequivalent. Tests.getRowKey->idKeygap and the column-model decision. Ship a codemod if the internal consumer count justifies it.useTableRowExpansion(patch). JSDoc@deprecated+ a docs banner pointing to the tree plugin, keeping it functional. Update the non-plugin references:apps/sandbox/.../table-lab/page.tsx,apps/storybook/stories/TableRowExpansion.stories.tsx,packages/cli/templates/blocks/components/Table/TableRowExpansionTable.tsx+.doc.mjs, theTable/index.tsexports, and the{@link useTableRowExpansionState}reference inuseTableGroupedRows.tsx.useTableRowExpansion(major, later). Delete the plugin directory and drop the exports. Only after consumers have migrated.Notes
minor/patch). Only step E is amajor.useTableRowExpansionin fix(Table): guard rowExpansion tree walks against cyclic data #4070 becomes redundant once the plugin is removed in step E; the tree plugin already has its own guard from feat(table): tree data plugin — useTableTreeState + useTableTreeData #3789. No action, just so no one is surprised.useTableGroupedRowsonly referencesuseTableRowExpansionin a doc{@link}comment, not in code, so there is no code dependency to untangle.Fallback if we must keep both
If back-compat forces keeping
useTableRowExpansionas a distinct plugin, do not keep two independent tree walks. Extract the shared flatten / depth / expand-all / cycle-guard logic into one internal util both plugins consume. Convergence is preferred; this is the floor.humbertovirtudes commentedon Jul 22, 2026
PR #4172 (draft) implements step 1 of the plan above: the expand-all/collapse-all header control folded into useTableTreeData + useTableTreeState. Whole-row-click, the migration doc, and deprecation follow in separate PRs.
feat(core): add expand-all header control to Table tree plugin (meta#…
feat(core): add expand-all header control to Table tree plugin (meta#…
feat(core): add expand-all header control to Table tree plugin (meta#…
feat(core): add expand-all header control to Table tree plugin (meta#…
feat(core): add expand-all header control to Table tree plugin (meta#…
feat(core): add expand-all header control to Table tree plugin (meta#…
feat(core): add expand-all header control to Table tree plugin (meta#…
feat(core): add expand-all header control to Table tree plugin (#4142) (
feat(core): Table tree whole-row-click expansion (#4142) (#4548)
humbertovirtudes commentedon Jul 31, 2026
PR #4584 implements step 3 of the plan: the migration guide from useTableRowExpansion to useTableTreeData + useTableTreeState (before/after example + config mapping) on the useTableRowExpansion docs. Deprecation (step D) and removal + codemod (step E) follow.
docs(core): add useTableRowExpansion to tree-plugin migration guide (#…
humbertovirtudes commentedon Jul 31, 2026
PR #4587 implements step 4 (soft-deprecate): @deprecated JSDoc on useTableRowExpansion + useTableRowExpansionState and a Deprecated: marker in the docs, pointing to the tree plugin and the migration guide. Non-breaking; the hooks still work. Step 5 (removal + version-keyed codemod) is the last one.
docs(core): soft-deprecate useTableRowExpansion for the tree plugin (#…
humbertovirtudes commentedon Jul 31, 2026
PR #4609 takes the convergence in a different direction, per discussion: instead of removing useTableRowExpansion, it repurposes it as a detail-panel plugin (renderExpanded), so the two plugins are distinct (tree = hierarchy, rowExpansion = detail panel). This supersedes the deprecate/remove path. The soft-deprecation PR #4587 should be closed rather than merged.
feat(core): make useTableRowExpansion a detail-panel plugin (meta#4142)
feat(core): make useTableRowExpansion a detail-panel plugin (meta#4142)
feat(core): make useTableRowExpansion a detail-panel plugin (#4142) (#…
humbertovirtudes commentedon Aug 11, 2026
PR #4884 adds the automated migration codemod (migrate-table-rowexpansion-to-tree) for consumers moving off the old tree-mode useTableRowExpansion, following the plugin change in #4609. Runs on astryx upgrade; detail-panel usage is left untouched.
feat(cli): add codemod to migrate tree-mode useTableRowExpansion to t…
feat(cli): add codemod to migrate tree-mode useTableRowExpansion to t…
humbertovirtudes commentedon Aug 11, 2026
Converged and shipped
This is complete.
useTableTreeData+useTableTreeStateanduseTableRowExpansionare now two plugins with distinct, non-overlapping purposes, and there is an automated migration path between the old world and the new one.The two plugins, differentiated
useTableTreeData+useTableTreeStateown hierarchy: nested/child rows that reuse the parent's columns, with expand/collapse, an expand-all header control, and whole-row-click expansion.useTableRowExpansionowns master-detail:renderExpanded(item)renders a full-width detail panel below a row (accordion / detail-drawer patterns). This restored its original design intent instead of deleting it.The redundant tree affordances that used to live in
useTableRowExpansionwere folded into the tree plugin, and the tree-flatten helperuseTableRowExpansionStatewas removed (tree users move touseTableTreeState).What shipped
useTableTreeState+useTableTreeDatatree data pluginuseTableRowExpansionto tree-plugin migration guideuseTableRowExpansionas a detail-panel plugin (renderExpanded); removeuseTableRowExpansionState; re-add the additiveafterRowcore primitivemigrate-table-rowexpansion-to-treecodemod (runs onastryx upgrade)Direction note
The plan started by leaning toward deprecating
useTableRowExpansion(the soft-deprecation docs in #4587). During implementation the direction changed: rather than remove a useful plugin, #4609 repurposed it for the master-detail pattern it was originally designed for. The result keeps both plugins, each with a clear job, and supersedes the deprecation framing.Migration for consumers
v0.3.0codemod (feat(cli): codemod to migrate tree-mode useTableRowExpansion to the tree plugin (#4142) #4884) rewrites the old tree pattern automatically:useTableRowExpansionState->useTableTreeState,useTableRowExpansion(config)->useTableTreeData(treeConfig), remapping every config field and fixing imports. It leaves an inline note where the controlled expansion-state wiring needs a human eye, and it leaves the new detail-panel usage (renderExpanded) untouched.Closing as done. The breaking change and its automated escape hatch both land in
v0.3.0.