Skip to content

feat(core): make useTableRowExpansion a detail-panel plugin (#4142) - #4609

Merged
humbertovirtudes merged 1 commit into
meta:mainfrom
humbertovirtudes:feat/row-expansion-detail-panel
Aug 11, 2026
Merged

humbertovirtudes merged 1 commit into
meta:mainfrom
humbertovirtudes:feat/row-expansion-detail-panel

Conversation

@humbertovirtudes

Copy link
Copy Markdown
Contributor

Summary

Resolves the useTableRowExpansion / tree-plugin overlap tracked in #4142 by differentiation instead of removal. Rather than deprecating and deleting useTableRowExpansion, this repurposes it for a distinct job, so both plugins earn their place:

  • useTableTreeData + useTableTreeState own hierarchy: nested child rows that reuse the parent columns, indented by depth (expand-all, whole-row click, cycle guard).
  • useTableRowExpansion owns the detail panel: a full-width panel below a row, rendered by the consumer via renderExpanded(item). This is the master-detail / accordion-row pattern (order details, forms, charts, nested tables).

This is the plugin's original design (it shipped as a renderExpanded detail panel before being refactored into the inherited-columns tree), so it restores a proven shape rather than inventing one.

Breaking change

  • useTableRowExpansion config is now { expandedKeys, onToggle, getRowKey, renderExpanded, getIsItemExpandable? }. renderExpanded is required; the consumer owns expandedKeys (via useState).
  • useTableRowExpansionState is removed. It was a tree flattener; a detail panel does not flatten a tree.
  • If you used useTableRowExpansion for tree rows, migrate to useTableTreeData + useTableTreeState. A before/after example is on the useTableRowExpansion docs (astryx component useTableRowExpansion --detail full).

What changed

  • Core (additive): re-add afterRow to BodyRowRenderProps + BaseTable, a small hook so a plugin can append a full-width <tr> after a row. The detail panel spans all columns via the tracked final column count (no colSpan={999} hack).
  • Plugin: useTableRowExpansion rewritten to detail-panel mode: leading chevron column, right-click expand/collapse action, renderExpanded panel below each expanded row. The inherited-columns tree rendering is removed (that lives in the tree plugin).
  • Story + example block: rewritten to a master-detail orders example.
  • Docs: useTableRowExpansion.doc.mjs rewritten for the detail-panel API, with a "migrating tree rows to the tree plugin" example. groupedRows doc link repointed to useTableTreeState.

Config mapping (tree rows -> tree plugin)

old useTableRowExpansion(State) useTableTreeState / useTableTreeData
baseData (nested) data
getChildren: item => item.children childrenKey: 'children'
getRowKey: item => item.id idKey: 'id' or idKey={item => item.id}
getIsItemExpandable isItemExpandable
expandedKeys + setExpandedKeys defaultExpandedIds or expandedIds + onExpandedIdsChange
isAllExpanded + onToggleExpandAll hasExpandAllControl

Test plan

  • 13 detail-panel unit tests (RED-verified before implementation): chevron per expandable row, panel renders below on expand, full-width colSpan = all columns, per-row panels, non-expandable rows, context-menu action, i18n label.
  • Full core Table suite green; tsc (core + docs) clean; eslint clean; check:changesets valid.
  • afterRow is additive and defaulted-off, so other Table plugins are unaffected.

Supersedes

This replaces the earlier "deprecate + remove" plan. The soft-deprecation PR (#4587) should be closed rather than merged, since we are keeping the plugin.

Note for maintainers

The one core API-surface addition is afterRow on BodyRowRenderProps. It is small, additive, and defaulted-off, and it is what the plugin originally used. Flagging it explicitly since it is a Table-core primitive.

@vercel

vercel Bot commented Jul 31, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
astryx Ready Ready Preview Jul 31, 2026 7:43pm

Request Review

@github-actions

github-actions Bot commented Jul 31, 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

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

Bundle Size Summary

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

Accessibility Audit

Status: No accessibility violations detected.


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

github-actions Bot added a commit that referenced this pull request Jul 31, 2026
Resolves the tree/rowExpansion overlap by differentiation instead of
removal. The two plugins now serve distinct jobs:

- useTableTreeData + useTableTreeState: hierarchy (child rows that reuse
  the parent columns, indented by depth).
- useTableRowExpansion: a full-width detail panel below a row, rendered
  by the consumer via renderExpanded(item): master-detail rows (order
  details, forms, charts, nested tables).

BREAKING:
- useTableRowExpansion config is now { expandedKeys, onToggle, getRowKey,
  renderExpanded, getIsItemExpandable? }. renderExpanded is required.
- useTableRowExpansionState is removed. For tree rows, migrate to
  useTableTreeState (see the migration example on the docs).

Core: re-add afterRow to BodyRowRenderProps + BaseTable, a small
additive hook so a plugin can append a full-width <tr> after a row. The
panel spans all columns via the tracked column count.

Story, example block, and docs rewritten for the detail-panel model;
groupedRows doc link repointed to useTableTreeState.

Tests: 13 detail-panel unit tests (RED-verified first); full core Table
suite green; core + docs tsc clean; eslint clean; changeset valid.
@humbertovirtudes
humbertovirtudes force-pushed the feat/row-expansion-detail-panel branch from 997563c to 73ecd73 Compare August 11, 2026 05:04
@vercel

vercel Bot commented Aug 11, 2026

Copy link
Copy Markdown

@humbertovirtudes is attempting to deploy a commit to the Meta Open Source Team on Vercel.

A member of the Team first needs to authorize it.

github-actions Bot added a commit that referenced this pull request Aug 11, 2026
@humbertovirtudes
humbertovirtudes merged commit 52a0e0e into meta:main Aug 11, 2026
17 of 18 checks passed
humbertovirtudes added a commit to humbertovirtudes/astryx that referenced this pull request Aug 11, 2026
…he tree plugin (meta#4142)

useTableRowExpansion became a detail-panel plugin (meta#4609) and
useTableRowExpansionState was removed. This adds a v0.3.0 codemod so
`astryx upgrade` migrates the old tree pattern automatically:

  const {data, expansionConfig} = useTableRowExpansionState({
    baseData, getChildren, getRowKey, expandedKeys, setExpandedKeys,
  });
  const expansion = useTableRowExpansion(expansionConfig);

becomes:

  const {visibleData: data, treeConfig} = useTableTreeState({
    data: baseData, childrenKey: 'children', idKey: getRowKey, ...
  });
  const expansion = useTableTreeData(treeConfig);

It remaps the config (baseData -> data, getChildren -> childrenKey,
getRowKey -> idKey, getIsItemExpandable -> isItemExpandable), fixes the
imports, and leaves a guidance comment about expansion state (the
controlled expandedKeys/setExpandedKeys mapping is not mechanical).
Detail-panel usage (renderExpanded, no useTableRowExpansionState import)
is left untouched.

Tests: 10 unit tests (RED-verified first); full v0.3.0 codemod suite
green (104); registered in the v0.3.0 manifest; eslint + changeset clean.
humbertovirtudes added a commit that referenced this pull request Aug 11, 2026
…he tree plugin (#4142) (#4884)

useTableRowExpansion became a detail-panel plugin (#4609) and
useTableRowExpansionState was removed. This adds a v0.3.0 codemod so
`astryx upgrade` migrates the old tree pattern automatically:

  const {data, expansionConfig} = useTableRowExpansionState({
    baseData, getChildren, getRowKey, expandedKeys, setExpandedKeys,
  });
  const expansion = useTableRowExpansion(expansionConfig);

becomes:

  const {visibleData: data, treeConfig} = useTableTreeState({
    data: baseData, childrenKey: 'children', idKey: getRowKey, ...
  });
  const expansion = useTableTreeData(treeConfig);

It remaps the config (baseData -> data, getChildren -> childrenKey,
getRowKey -> idKey, getIsItemExpandable -> isItemExpandable), fixes the
imports, and leaves a guidance comment about expansion state (the
controlled expandedKeys/setExpandedKeys mapping is not mechanical).
Detail-panel usage (renderExpanded, no useTableRowExpansionState import)
is left untouched.

Tests: 10 unit tests (RED-verified first); full v0.3.0 codemod suite
green (104); registered in the v0.3.0 manifest; eslint + changeset clean.
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. needs:design-review Affects visuals — Design should review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant