Skip to content

feat(Table): add row-specific expansion labels - #6776

Merged
humbertovirtudes merged 1 commit into
meta:mainfrom
humbertovirtudes:fix/table-row-expander-names
Nov 4, 2026
Merged

humbertovirtudes merged 1 commit into
meta:mainfrom
humbertovirtudes:fix/table-row-expander-names

Conversation

@humbertovirtudes

@humbertovirtudes humbertovirtudes commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

User need

Screen-reader users navigating expandable Table rows hear repeated generic control names. The caller has each row's identity, but the detail-row and tree hooks cannot infer it from generic data or custom columns.

Solution and current authority

Optional getRowLabel?: (item: T) => string on both existing expansion hooks supplies identity only. Astryx supplies localized expand/collapse wording. Surrounding whitespace is trimmed; blank/omitted input retains generic names. The context-menu action remains generic.

The missing naming-only contracts are now proposed separately in #9859 at 06bc5dc87eaa698e8c3f7f8ee4ab40aca8379f9a. They remain draft, with approval metadata unset. Table owns aggregate placement and composition; the proposed module records cover only accessible names, not complete tree anatomy or selection-label policy. Approval and release wait for the engineering owner's contract decision and required review gates.

Caller example

const expansion = useTableRowExpansion({
  expandedKeys,
  onToggle,
  getRowKey: item => item.id,
  renderExpanded,
  getRowLabel: item => item.customer,
});
const tree = useTableTreeData({...treeConfig, getRowLabel: item => item.name});

Callers opt in only when they have a human-readable identity. Names are not row keys, complete action labels or a new expansion-state source. There is no migration for callers who omit the callback. Selection's existing callback and blank behavior are unchanged.

Refresh and compatibility repair

Rebased the same PR onto main ccfadbef8225423ecf6f16ba479a3c7775f3991a. Current main still lacks both callbacks. Upstream component-local English fallback translators and existing motion, divider, layout and interaction behavior are preserved.

The earlier implementation moved detail-chevron translation into the hook caller, breaking providers wrapped around only Table. The refreshed control resolves the trimmed identity inside its rendered component's provider. Three actual Table tests for omitted, blank and named labels fail before the repair and pass afterwards; they also check provider locale changes. Header and context-menu translations retain their existing caller boundary; this is not a global plugin-localization rewrite.

Verification at the refreshed source

  • 91 focused expansion/tree tests pass, including the three mutation-sensitive provider regressions.
  • 685 complete Table and consumer-document tests pass across32 files on immutable refreshed source.
  • Core source/declaration build, generated API report check, strict changed-file lint, catalog, knowledge, formatting and pre-review checks pass.
  • Test-inclusive core TypeScript retains one unchanged TokenizerBottomSheet experimental-prop test error, identical to pinned main. It is disclosed rather than claimed green.
  • Real Chromium reads the canonical detail-panel/tree stories: top-level and nested names change while role/state remain, native Tab/Enter/Space preserves control/focus, label-only tree updates remain covered, provider-wrapped Table names follow French/German locale changes, and menu copy stays generic.
  • Matched light/dark source-story captures are pixel-identical on exact main plugin sources and the refreshed plugin sources. This is computed-name/browser evidence, not spoken AT or hosted preview certification.

Review and scope

One naming capability,11 files including tests/docs/catalog/generated API report. Independent read-only review found no blocking naming defect. It notes unchanged generic/leaf tree snapshots can cause a minor unnecessary rerender on label configuration changes; no render loop or measured regression is claimed. Existing header/menu provider boundaries remain out of scope.

No approval, lifecycle transition, merge, request to a human reviewer or duplicate runtime PR is performed by this refresh. #9859 and independent code/spec review gates must be satisfied before release.

This PR was generated with AI assistance (Navi).
Tags: ai-generated

Retained browser evidence

Matched before/after frames and binding and native keyboard/provider demo (VP9/tv; initial page startup is blank).

Light-mode source story

Dark-mode source story

Approved-contract merge preparation

The engineering owner approved the naming contract in #9859; its current records are posted at 4c500ee and wait for normal CI/merge. This implementation remains held until those records are on main.

Rebased onto main 1800b47. All Table plugin and story sources remain byte-identical to bef8df2. A fresh source/declaration build, full core typecheck and 156 expansion/tree/Table accessibility and menu integration tests pass. The earlier Tokenizer baseline error is fixed on this main base; the old failure receipt is historical, not current. Native row-name/provider/Tab/Enter/Space/menu checks are rerun against this base; the API report catches up the upstream duration-exit token. No new runtime naming behavior, spec decision or review bypass.

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

astracat-bot Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🔄 In progress (for maintainers only) Nov 4, 2026, 4:30 AM UTC

@vercel

vercel Bot commented Sep 30, 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 4, 2026 4:30am UTC

Request Review

@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · bef8df2

This branch's preview address cannot be known in advance; open it from Vercel's comment.

Current run: The current CI run concluded failure. Current analysis is unavailable.


Generated by PR Enrichment workflow | View current CI run

@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 clear write-up and the focused coverage — the implementation itself looks ready, but approval needs one maintainer decision first.

This adds a new public API that isn't settled yet: the optional getRowLabel(item) callback on both useTableRowExpansion and useTableTreeData, producing localized names like "Expand Alan Turing" while keeping the generic "Expand row" / "Collapse row" names when the callback is omitted or returns blank text. The current Table contract owns the stable expansion control but leaves new public API and module-local API decisions to their owning records, and no current record yet admits this callback for either plugin. Tests, docs, and the Changeset can't substitute for that admission.

Could a Table API maintainer please provide or identify the governing spec for this addition — covering both plugins, the callback name and type, the blank/omitted fallback, the new named localized messages, and keeping the detail-row context-menu action generic — or say if it shouldn't proceed? Once that spec is in place, this change can be re-reviewed on its merits.

For context on readiness: the focused tests cover named, nested, blank-fallback, and omitted-callback names in both plugins (independently rerun and passing, along with the doc and tree-performance suites), the i18n catalog check passes, and existing callers are unaffected unless they opt in. No code changes are being requested for the missing spec itself.

[Automated review]

@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 focused change and tests; approval is on hold for one owner decision, plus one small fix.

getRowLabel(item) on useTableRowExpansion and useTableTreeData is new public API that no current spec admits yet, so an engineering owner needs to provide or identify its governing spec (the callback’s name and type on both plugins, the omitted/blank fallback and whether it should match the selection plugin’s getRowLabel, the four *RowNamed messages, and keeping the context-menu action generic) and record that decision by commenting /approve-spec 4d6ec6d830f8d41bddfab4dd96cef2bd03ef0698 on this pull request, which you can do yourself as an engineering owner.

Separately, the detail-row chevron now takes its generic label from the hook caller’s translator instead of the Table’s own, so an InternationalizationProvider that wraps only the Table no longer localizes it, even without getRowLabel; keeping useTranslator() in ExpansionChevron and passing the row label down, as the tree expander already does, fixes it.

[Automated review]

isExpanded: boolean;
onToggle: () => void;
}) {
const t = useTranslator();

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.

Removing this translator means the chevron's name now comes from the hook caller's t (line 608 on the new side). When an InternationalizationProvider wraps only the <Table>, the chevron used to follow it (“Développer la ligne”); it now falls back to the caller's context (“Expand row”), even without getRowLabel. Keeping useTranslator() here and passing the trimmed row label down, as TreeExpander does, keeps the released behavior.

@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 focused update: the earlier provider-localization issue is fixed, and no code changes are requested. Approval is on hold for one engineering-owner decision.

getRowLabel(item) on useTableRowExpansion and useTableTreeData is new public API that no current spec admits yet. An engineering owner needs to provide or identify its governing spec, covering:

  • the callback's name and type on both plugins;
  • the trim and blank fallback, including whether it should match the selection plugin's getRowLabel, which treats an empty string as a name;
  • the four *RowNamed messages;
  • keeping the detail-row context-menu action generic.

Approving the draft records proposed in #9859 would settle this, or an engineering owner can record the decision by commenting /approve-spec bef8df211f2a3b1b94e68845f917d3029b7d2c75 on this pull request; the author may do so as an engineering owner.

[Automated review]

Comment on lines +182 to +185
* Encode a row's tree meta and optional accessible label as a primitive for
* useSyncExternalStore — object snapshots would tear. The numeric fast path is
* retained when getRowLabel is absent. When it is present, the derived label
* participates so config-only label changes re-render the affected cells.

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 comment-style suggestion: "The numeric fast path is retained when getRowLabel is absent" is passive and restates the if (!config.getRowLabel) line below. A shorter version keeps only the reason:

/**
 * useSyncExternalStore needs a primitive snapshot. An object snapshot tears.
 * The label is part of the snapshot, so a label-only change re-renders the cell.
 * Encoding: level * 16 + indentIndex * 4 + hasChildren * 2 + isExpanded;
 * -1 = no meta.
 */

@humbertovirtudes humbertovirtudes added the ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) label Nov 4, 2026
Let detail-row and tree expansion controls include caller-provided row identities in localized accessible names while preserving the existing generic fallback.

This change was developed with AI assistance.

Rebased with AI assistance (Navi); resolved expansion source/test conflicts while preserving the existing row-label behavior and upstream motion/divider handling.
Tags: ai-generated
@humbertovirtudes
humbertovirtudes force-pushed the fix/table-row-expander-names branch from bef8df2 to 52db870 Compare November 4, 2026 04:21
@humbertovirtudes
humbertovirtudes enabled auto-merge (squash) November 4, 2026 04:34
@humbertovirtudes
humbertovirtudes merged commit 31ab2c3 into meta:main Nov 4, 2026
60 checks passed

This branch was successfully deployed

1 active deployment
Preview — 52db8704 Deployed Nov 4, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) 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