Skip to content

feat(core): Table tree whole-row-click expansion (#4142) - #4548

Merged
humbertovirtudes merged 1 commit into
meta:mainfrom
humbertovirtudes:feat/tree-row-click
Jul 31, 2026
Merged

humbertovirtudes merged 1 commit into
meta:mainfrom
humbertovirtudes:feat/tree-row-click

Conversation

@humbertovirtudes

Copy link
Copy Markdown
Contributor

Summary

Second step of the tree-plugin convergence tracked in #4142: fold useTableRowExpansion's whole-row-click affordance into useTableTreeData as an opt-in hasRowClickExpansion prop. (The header expand-all control was the first step, #4172.)

When set, clicking anywhere on an expandable row toggles its expansion, in addition to the chevron.

What changed

  • useTableTreeData: new hasRowClickExpansion?: boolean prop (default false). When enabled, transformBodyRow attaches an onClick to expandable rows plus a clickableRow (cursor: pointer) style. Leaf rows stay inert and the whole feature is a no-op on flat data.
  • Guards for clean composition: the row handler ignores clicks that originate from interactive cell content (button, a, input, select, textarea, [role="button"], [role="checkbox"], [contenteditable]) and clicks that produced a text selection. So composing with the selection plugin, a checkbox click selects the row without toggling expansion. The chevron already stops propagation, so it never double-toggles.
  • Accessibility: this is a pointer-only convenience. Keyboard and assistive-tech users continue to toggle via the chevron button, which stays the accessible control. Documented in the config JSDoc and the doc.mjs prop entry.

Why converge here

Per #4142, useTableTreeData is the stronger base to keep (fine-grained per-row re-render, cycle guard, imperative row ARIA). With expand-all (#4172) and now row-click folded in, it covers useTableRowExpansion's affordances. Notably, the older plugin has no guard against nested interactive content or text selection on its row-click; this port adds both, so we converge toward the more correct behavior rather than porting the gap forward.

Test plan

  • Colocated unit tests in useTableTreeData.test.tsx (8 cases): prop off (inert), expand on body click, collapse on body click, leaf inert, chevron single-toggle (spy asserts toHaveBeenCalledTimes(1)), no-op on flat data, and composition with the selection checkbox (checkbox click does not toggle).
  • New Storybook story Core/TableTree > RowClickExpansion.
  • pnpm -F @astryxdesign/core test (tree suite 77 passing), typecheck, typecheck:docs, and storybook typecheck all green.

Fold useTableRowExpansion's whole-row-click affordance into useTableTreeData
as an opt-in `hasRowClickExpansion` prop. When set, clicking anywhere on an
expandable row toggles it, in addition to the chevron.

The row handler ignores clicks that originate from interactive cell content
(buttons, links, form controls, e.g. a composed selection checkbox) and clicks
that produced a text selection, so it composes cleanly with the other Table
plugins. Keyboard and assistive-tech users continue to toggle via the chevron
button, which stays the accessible control. Leaf rows stay inert and the whole
feature is a no-op on flat data.

Second step of the tree-plugin convergence: with expand-all and row-click both
folded in, useTableTreeData now covers useTableRowExpansion's affordances on a
stronger base (fine-grained re-render, cycle guard, row ARIA).
@vercel

vercel Bot commented Jul 30, 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 30, 2026 2:42pm

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jul 30, 2026
@github-actions

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 · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 1938 -
Complexity N/A Very High (110) -

Bundle Size Summary

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

Accessibility Audit

Status: 1 accessibility violation(s) found — 1 serious.

Table - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 4/24 stories · Learn more
    • WCAG: 1.4.3 (Level AA)

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

github-actions Bot added a commit that referenced this pull request Jul 30, 2026
@humbertovirtudes
humbertovirtudes marked this pull request as ready for review July 31, 2026 08:39
@humbertovirtudes
humbertovirtudes merged commit ca5837c into meta:main Jul 31, 2026
20 checks passed
humbertovirtudes added a commit that referenced this pull request Jul 31, 2026
…4142) (#4584)

The tree plugins are converging: useTableTreeData + useTableTreeState now
cover useTableRowExpansion's affordances (expand-all header control #4172,
whole-row click #4548) with a cycle guard and fine-grained re-render.

Add a migration guide to the useTableRowExpansion docs so consumers have a
clear path to the surviving plugin:
- a before/after example (useTableRowExpansion + State -> useTableTreeState
  + useTableTreeData)
- a full config mapping (baseData -> data, getChildren -> childrenKey,
  getRowKey -> idKey, getDepth removed, isAllExpanded/onToggleExpandAll ->
  hasExpandAllControl, hasRowClickExpansion unchanged)

Surfaces via `astryx component useTableRowExpansion --detail full` and the
docs pipeline. Deprecation and removal follow in later changes.
humbertovirtudes added a commit that referenced this pull request Jul 31, 2026
…4142) (#4587)

Fourth step of the tree-plugin convergence. useTableTreeData +
useTableTreeState now cover useTableRowExpansion's affordances
(expand-all header control #4172, whole-row click #4548) with a cycle
guard and fine-grained re-render, and the migration guide landed in
#4584.

Mark the older plugin deprecated without removing it:
- @deprecated JSDoc on useTableRowExpansion and
  useTableRowExpansionState (and the file header), each pointing to the
  tree plugin and the migration guide.
- Prefix the doc.mjs descriptions with "Deprecated: use useTableTreeData
  + useTableTreeState instead", so it shows in the docs and via
  `astryx component useTableRowExpansion`.

The hooks still work; existing consumers are unaffected. Removal and a
version-keyed codemod follow in a later release.

This branch was successfully deployed

1 active deployment
Preview — 5a03a00f Deployed Jul 30, 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant