Skip to content

feat(Table): row-expansion panel indent, panelVariant and hasRowClickExpansion - #6480

Closed
ernestt wants to merge 1 commit into
core-row-expansion-chevron-indentfrom
core-row-expansion-panel-api
Closed

ernestt wants to merge 1 commit into
core-row-expansion-chevron-indentfrom
core-row-expansion-panel-api

Conversation

@ernestt

@ernestt ernestt commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

What

The half of #5995 that adds public surface or changes a released default. Stacked on #5995 — review that one first; this branch targets it, not main.

fix the detail panel started at the row edge
feat panelVariant — opt the panel's wash out, and flip the default
feat hasRowClickExpansion — the whole row toggles, as in useTableTreeData
fix both expansion plugins share the clickable-container guards

Split out so the three uncontested repairs in #5995 are not held behind the decisions here. Two change requests are open against this material and are addressed below, except where they are genuinely open questions for an owner.


Open, and needing a decision

1. The panel indent assumes the chevron is the leading column. humbertovirtudes' fifth probe. The indent is calc(--spacing-10 + <density padding>) — the chevron column's width plus a cell's own inline padding — which is correct only while the chevron is first. Add a selection checkbox or a row-index column and the panel lands a column short.

The plugin already makes exactly this assumption for the panel's colSpan (columnCountRef is captured in transformColumns, so a plugin that prepended a column later would throw both off), so this is the same latent limit in a second place rather than a new one. It is still wrong, and it is wrong in the combination people actually build: selection plus expansion is the common pairing.

The fix wants the leading-column offset derived from the resolved column set rather than assumed, which means the plugin needs to know what ran before it. That is a shape question about the plugin protocol, not a patch — flagging rather than guessing.

2. hasRowClickExpansion and the selection plugin. cixzhang asked this to match the selection plugin's row-click option. useTableSelection has no row-click option today; the one precedent is useTableTreeData.hasRowClickExpansion, which this copies exactly — same name, same false default, same guards.

The open question is the one underneath: a table with both plugins and both flags on has one click and two meanings. Which wins, or is the combination refused? Worth deciding before this surface lands, because the answer may change the shape.

3. No plugin has a .spec.md. The combinations that need writing down for this one are rowExpansion × striping, × selection, × groupedRows, × stickyColumns, × dividers. Happy to do a design-only plugin spec record first and rebase this onto it, same shape as the #6194 → #6232 split.


fix — the panel started at the row edge

The panel is one cell spanning the whole row with a flat 20px inline padding, so its content began under the chevron — a column to the left of every label it describes. It now indents to the first real column:

panel alignment

The start padding is the chevron column's fixed width plus the inline padding a cell of that density gives its own content — calc(--spacing-10 + var(--spacing-3)) at balanced. Density comes off the table context, which is why the panel had to become a small component (ExpansionPanelCell) rather than a bare <td>: the plugin builds this row inside transformBodyRow, outside the Table's own render, so the context is not otherwise in hand. (#5995 already introduces that component to carry the row divider; this adds the indent to it.)

It is a logical property, so RTL mirrors it, and it is not configurable — a panel starting anywhere else reads as a misalignment rather than as a choice.

EXPANSION_COLUMN_WIDTH_PX = 40 stays a number, because a column width is arithmetic the layout does rather than a CSS value. But 40px is --spacing-10, and the indent spells it as the token, so a test pins the rendered column width to spacingDefaults['--spacing-10'] — the two silently drifting apart would unalign the panel.

Known limit: see open question 1 above.

The indent also lands 1px short, and that 1px is not mine. Measured in the browser: panel content at x=184, first column's text at x=185. The formula is exact; the gap is the UA stylesheet's td { padding: 1px } leaking into cells that own a context menu. TableCell relocates density padding onto the right-click trigger for those cells and leaves the <td> with font/box-sizing only — no padding — which is true of the authored rules but not of the computed result. This plugin puts a context menu on every cell, so every one carries the stray pixel. The fix is a one-line padding: 0 in TableCell, but it shifts every context-menu cell in the system by 1px in both axes, so it wants its own PR and its own visual pass.

feat — panelVariant

The panel's muted wash was hardcoded, and being a <tr> the plugin builds itself, nothing a caller rendered could reach it.

The default flips to transparent. The panel is the row's continuation, not a surface of its own, so it takes whatever the table sits on — the same thing the row does. A table on a Card no longer stacks a third surface, and a striped table no longer paints a band in the same token as its own stripe, which read as a data row rather than as a detail. 'muted' stays available for the bare table — no card, no dividers, no striping — where nothing else separates the panel from the data.

'muted' 'transparent' (new default)
muted transparent

This changes the default appearance — called out in the changeset. A table relying on the wash gets it back with panelVariant: 'muted'. In dark themes there is nothing to get back: --color-background-muted and --color-background-card resolve to the same value there, so dark has effectively been rendering transparent all along. The prop is really a light-mode affordance; in dark it mostly decides what happens when the theme later separates those two tokens.

feat — hasRowClickExpansion

useTableTreeData already lets the row body toggle its own disclosure; this plugin only accepted the chevron, so two tables with the same affordance behaved differently depending on which plugin drew it. Same prop name, same default of false, so nothing changes for existing callers.

useTableRowExpansion({
  renderExpanded: item => <AccountDetail account={item} />,
  hasRowClickExpansion: true,
});

Off by default and pointer-only; the chevron button stays the accessible control, so keyboard and assistive-tech users are unaffected. The handler steps aside for anything with its own answer to a click, and for a live text selection, so dragging across a cell to copy a figure does not also collapse what you were reading. Collapsed rows are wired up too, which is most of the point — the row worth clicking is the one that has not opened yet. Rows the predicate rules out stay inert and keep the default cursor.

row hover

row opened

fix — share the clickable-container guards

Both expansion plugins carried their own copy of the nine-selector "did this click belong to something else" check. useClickableContainer already owns that rule for every clickable surface in the system, with a fuller list — role="link", radio, switch, tab, menuitem, option, combobox, listbox, slider, spinbutton, [data-pressable-container] — and an [aria-readonly="true"] exclusion.

The hook itself wants a ref to the container, and a <tr> assembled inside transformBodyRow has none to hand it, so this exports the two guards it is built from — hasInteractiveAncestor and hasTextSelection — and calls those from both plugins. One definition, three callers.

This is the part that adds surface without looking like it. Two new exports on the hooks barrel are a public promise, and R1g-surface judges an export the same way it judges a prop. Worth saying plainly rather than filing as a dedupe.

Two behaviour fixes fall out of sharing:

  • A click on a composed control the short list missed — a role="tab", a segmented role="radio", a Slider in a cell — no longer toggles the row underneath it.
  • The selection guard is scoped to the row instead of asking the document for any selection. Text selected in a sidebar no longer makes every row inert.

Test plan

  • vitest run packages/core/src/Table packages/core/src/hooks — 568 passed across 26 Table files on the stack.
  • tsc --noEmit and eslint clean; full pre-commit check suite green.
  • 14 new cases over feat(Table): make row expansion behave like its sibling plugins #5995's 8:
    • panel placement (3) — start padding is calc(--spacing-10 + var(--spacing-3)) at the default density; follows density to --spacing-4 at spacious; the chevron column's width is pinned to spacingDefaults['--spacing-10'].
    • panel variant (2) — on the surface behind the table by default, washed when muted is asked for.
    • whole-row-click expansion (8) — inert by default; expands; collapses; no double-toggle from the chevron; yields to interactive cell content; yields to a text selection in the row; toggles despite a selection elsewhere on the page; leaves non-expandable rows inert; cursor: pointer only when wired up.

Four changesets included, one per change.

Still outstanding from review

humbertovirtudes' probes 1–4 — contenteditable clicks, preventDefault() from a prior handler, grouped-row empty-key panels, tree and detail both firing — are not addressed in this push. They are all hasRowClickExpansion composition, and they want the shape questions above settled first, since the answer to "which plugin owns the click" decides several of them.

@vercel

vercel Bot commented Sep 23, 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 Sep 23, 2026 7:09pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Sep 23, 2026
Stacked on the row-expansion fixes. Everything here either adds public
surface or changes a released default, which is why it is separate from
those.

panelVariant: 'muted' | 'transparent' — the panel row painted
--color-background-muted unconditionally, and being a <tr> the plugin
builds itself, nothing a caller rendered could reach it. The default
becomes transparent: the panel is the row's continuation, not a surface
of its own, so it takes whatever the table sits on. muted stays for the
bare table — no card, no dividers, no striping — where nothing else
separates the panel from the data. This changes the default appearance.

hasRowClickExpansion — the whole row toggles its panel, matching the
flag useTableTreeData has carried since it shipped. Off by default and
pointer-only; the chevron stays the accessible control.

Sharing the click guards: both expansion plugins carried their own copy
of the nine-selector "did this click belong to something else" check.
useClickableContainer already owns that rule with a fuller list, so its
hasInteractiveAncestor and hasTextSelection are exported for containers
that cannot use the hook itself — a <tr> assembled in transformBodyRow
has no ref to hand it — and both plugins call them.

The panel indent: the detail panel spanned the row with a flat inline
padding, leaving its content under the chevron, a column to the left of
every label it describes. It now indents by the chevron column's width
plus the density's own cell padding, read off the table context.
@astracat-bot

astracat-bot Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
❓ Needs maintainer input (for maintainers only) Sep 23, 2026, 8:18 PM UTC

@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 splitting the decision surface out and writing the trade-offs down — the panel alignment, panelVariant, and row-click work reads clearly, and the committed suite covering indent, variant, and the toggle/guard matrix passes.

I'm holding approval for a maintainer decision: there's no plugin spec recording the rowExpansion combinations (striping, selection, groupedRows, stickyColumns, dividers), so panelVariant's default flip and hasRowClickExpansion — including how row-click interacts with the selection plugin — don't have governing authority yet. Either a pointer to the spec that covers this surface, or a design-only plugin spec record first, would clear it.

Worth keeping visible alongside: the leading-column assumption in the panel indent and the 1px context-menu shortfall, until their follow-ups land.

[Automated review]

@ernestt

ernestt commented Sep 23, 2026

Copy link
Copy Markdown
Contributor Author

Changeset compliance

One release entry needs correction before merge:

  • .changeset/table-row-expansion-panel-variant.md explicitly changes a released default and gives the migration (panelVariant: 'muted'). Under the repository’s 0.x Changeset convention, that must be [breaking] with @astryxdesign/core: minor, not [feat] with patch.

Also update the three moved entries that still cite (#5995)—shared guards, panel variant, and row click—to (#6480) so the release notes point to the PR that now carries them. The other package coverage and categories are consistent with their deltas.

@ernestt

ernestt commented Sep 23, 2026

Copy link
Copy Markdown
Contributor Author

Closing — folded back into #5995.

The split was meant to let the three uncontested fixes move while the API questions were settled. It does not achieve that: both halves need an approval from a Table CODEOWNER (cixzhang, imdreamrunner, josephfarina, humbertovirtudes) to clear review-required, so splitting bought two review queues instead of one rather than an earlier landing.

Everything here is now on #5995, unchanged. The open questions this PR's description raised — the leading-column assumption in the panel indent, whether hasRowClickExpansion should be unified with the selection plugin's shape, and the missing plugin .spec.md — are carried over there.

No content is lost by this close; branch core-row-expansion-panel-api stays in place.

@ernestt ernestt closed this Sep 23, 2026
@github-actions
github-actions Bot deleted the core-row-expansion-panel-api branch September 24, 2026 06:23

This branch was successfully deployed

1 active deployment
Preview — 1fdd0f56 Deployed Sep 23, 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