Skip to content

feat(core): TableRow exposes a selected theme state - #11729

Merged
josephfarina merged 4 commits into
mainfrom
core-tablerow-selected-state
Nov 14, 2026
Merged

josephfarina merged 4 commits into
mainfrom
core-tablerow-selected-state

Conversation

@josephfarina

Copy link
Copy Markdown
Contributor

User need

A theme author who styles tables cannot style a selected row. useTableSelection paints the selection wash as an inline style and marks the row only with aria-selected, so no theme selector reaches it: a theme that wants a stronger selected fill, a bold label or a left accent on selected rows has no hook. The theme editor cannot offer --state selected on a table row for the same reason.

Problem and solution fit

A selected row now carries the table-row target's selected theme state (data-selected="selected"), written with the same themeDataAttributes helper every other theme state uses, beside aria-selected. A theme styles it with components: {'table-row': {selected: {…}}}. The inline wash is unchanged, so every existing table looks the same; a theme recolors the wash by setting --color-accent-muted in that state, which the inline background reads.

Current specification

  • component:TableRow FR5 (added here) names the state and why it is public theme surface, as architecture:public-component-api DEC-2 requires for a data attribute outside data-astryx-*.
  • architecture:component-theming-surface INV6: selection is reflected on the owning target through the theme state helpers.
  • component:Table FR6 now points to TableRow FR5.

Public delta and caller burden

  • New theme state selected on the table-row target, listed in Table's doc (states: ['selected']).
  • DOM: a selected row gains data-selected="selected"; it is removed on unselect, and it is set whatever hasRowHighlight is. Nothing else in the output changes: the inline wash, --table-row-overlay and aria-selected are as before.
  • Before: no way to theme selected rows. After:
components: {
  'table-row': {
    selected: {'--color-accent-muted': '#2563eb33', fontWeight: '600'},
  },
}
  • Callers of useTableSelection make no new decision.

Design and alternatives

The state follows the existing selection convention (selected: 'selected', as on Tab, SideNavItem, Item and others) and is written where aria-selected is, in the imperative row-styling path, so selection keeps re-rendering only the changed checkbox. Rejected: moving the wash from an inline style to a stylesheet rule keyed on the state. It would let a theme replace the background directly, but it changes the DOM of every selected row and the documented hasRowHighlight contract; the token route gives the same control with unchanged output.

Evidence

  • useTableSelection.test.tsx: the state appears only on the selected row and goes on unselect; it is kept with hasRowHighlight={false} (and no inline wash); a theme's compiled selected rule matches a selected row and not an unselected one.
  • themingTargets.test.ts passes with the new documented state.
  • Existing selection tests (aria-selected, select all, perf) pass unchanged.

Writing rubric results

R1 narration: none; FR5 and the Public concepts row describe present behavior, and Table FR6's status cell states the current fact.
R2 research: none in the record; the rejected alternative is one sentence in this description, not in the record.
R3 evidence: the new verification row names the test file and the cases, no pull request.
R4 rejected alternatives: none recorded.
R5 change references: none.
R6 open questions: none added.
R7 project status: none.

Scope

Components: Table, TableRow

  • One capability is added.
  • Unrelated fixes, cleanup, and policy changes were removed or split.
  • Consumer docs, focused tests, and migration evidence ship with the feature.
  • Public text and artifacts contain no internal Meta context.

Testing

  • vitest run --project ui packages/core/src/Table/plugins/selection packages/core/src/theme/themingTargets.test.ts
  • pnpm check:knowledge, node scripts/check-changesets.mjs, eslint and prettier on changed files.

… state

useTableSelection sets the table-row target's selected theme state (data-selected="selected") beside aria-selected and clears it on unselect, whatever hasRowHighlight is, so a theme can style selected rows. The inline selection wash is unchanged; a theme recolors it through --color-accent-muted in that state. Table's doc lists the state, and the TableRow record names it as public theme surface.
@vercel

vercel Bot commented Nov 14, 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 14, 2026 11:48am UTC

Request Review

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

astracat-bot Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 14, 2026, 12:06 PM UTC

@josephfarina

Copy link
Copy Markdown
Contributor Author

/approve-spec b677087

@github-actions github-actions Bot added the needs:design-review Affects visuals — Design should review label Nov 14, 2026
@josephfarina

Copy link
Copy Markdown
Contributor Author

/approve-spec 40f3d46

@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 98e6916

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
Table 137.9 kB (0) · 19.4 kB CSS (0) — — · — · —
TableBody 3.5 kB (0) · 3.3 kB CSS (0) — — · — · —
TableCell 121.0 kB (0) · 18.9 kB CSS (0) — — · — · —
5 more components
Component Size LoC Visual · A11y · RTL
TableFooter 3.5 kB (0) · 3.3 kB CSS (0) — — · — · —
TableHeader 3.5 kB (0) · 3.3 kB CSS (0) — — · — · —
TableHeaderCell 120.7 kB (0) · 18.7 kB CSS (0) — — · — · —
TableRow 7.1 kB (0) · 4.0 kB CSS (0) — — · — · —
TableSelectionToolbar 75.1 kB (0) · 14.0 kB CSS (0) — — · — · —

Package size:

  • @astryxdesign/cli 4.41 MB packed (+1.4 kB); no new dependencies
  • @astryxdesign/core 7.57 MB packed (+509 B); no new dependencies

API changes: core +0 · ~2 · −0

2 API changes (advisory)
Package Where Signature Usage
~ core Theme targets · target table-row (Table) target table-row (Table) → target table-row (Table) states [selected] defineTheme({components: {'table-row': {…}}})
~ core Public attributes · attr data-selected attr data-selected (theme reflection on 15 targets) → attr data-selected (theme reflection on 16 targets) [data-selected] { … }

Wide change (shared styles: packages/themes/probe/src/probeTheme.ts): add ci:run-visual, ci:run-a11y or ci:run-rtl to run them.


Generated by PR Enrichment workflow | View full report

@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.

Requesting changes: the selected theme state on table rows works as described, but the TableRow record still says this change leaves the DOM and the theme target untouched.

  • docs/specs/components/Table/TableRow.spec.md still reads "no API, default, or output changes" in its Compatibility/readiness row and "no public prop, default, DOM, target, or styling output changes" in its Compatibility class, while the new FR5 adds data-selected="selected" to selected rows and the selected state to the table-row target, so both lines should describe the change as additive.

Non-blocking: the new header sentence in useTableSelection.tsx reads more easily as three short sentences (see the inline suggestion). The three new tests fail before this change and pass after it, and in Chromium a theme rule that sets --color-accent-muted in the selected state recolours the selection wash as the release note says.

Claims and files checked
  • Release note: a row that useTableSelection selects carries the table-row selected state — verified (useTableSelection.tsx, new test "marks only selected rows…").
  • Release note: a theme styles it with components: {'table-row': {selected: {…}}} — verified (Table.doc.mjs declares the state; new test "matches a theme's selected table-row rule…").
  • Release note: the selection wash stays as it was — verified (wash code unchanged, existing wash tests pass, default rendering pixel-identical in Storybook).
  • Release note: a theme recolours the wash by setting --color-accent-muted in that state — verified (Chromium: the selected rows take the theme's colour).
  • Description: today a selected row is marked only with aria-selected and an inline wash, so no theme selector reaches it — verified against the base.
  • Description: the state is written with the shared theme attribute helper, beside aria-selected — verified.
  • Description: the state is removed on unselect and kept whatever hasRowHighlight is — verified (new tests).
  • Description: nothing else in the output changes (wash, row overlay variable, aria-selected) — verified (diff and existing tests).
  • Description: callers of useTableSelection make no new decision, and selection still re-renders only the changed checkbox — verified (no config change; the attribute rides the existing row ref; perf tests pass).
  • Description: TableRow FR5 names the state as public theme surface, Table FR6 points to it, and the theming-surface rule covers selection on the owning target — verified.
  • Description: theming-target tests, existing selection tests, the knowledge and changeset checks, eslint and prettier pass — verified.
  • Description: writing rubric results R1–R7 — verified.
  • File .changeset/table-row-selected-state.md — clear.
  • File docs/specs/components/Table/Table.spec.md — clear.
  • File docs/specs/components/Table/TableRow.spec.md — blocking finding above.
  • File packages/core/src/Table/Table.doc.mjs — clear.
  • File packages/core/src/Table/plugins/selection/useTableSelection.test.tsx — clear.
  • File packages/core/src/Table/plugins/selection/useTableSelection.tsx — non-blocking comment suggestion.
  • File packages/themes/probe/src/probeTheme.ts — clear (regenerated fixture; the generator's check reports it current).

Automated review (maintainer link)

…nts it with

The part data reads the paint Core writes inline when it sets a theme state at run time (the selection plugin's wash beside a row's selected state), so table-row in selected reads --color-accent-muted. how answers a selected-row background with that token on table-row --state selected, and a background there, which the inline wash would hide, is refused with that command.
@josephfarina

Copy link
Copy Markdown
Contributor Author

/approve-spec 98e6916

@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.

Requesting changes: the selected theme state on table rows and the theme editor's new answer for it both work, but the TableRow record's compatibility lines are still unchanged since the last review.

  • docs/specs/components/Table/TableRow.spec.md still reads "no API, default, or output changes" in its Compatibility/readiness row and "no public prop, default, DOM, target, or styling output changes" in its Compatibility class, while FR5 adds data-selected="selected" to selected rows and the selected state to the table-row target, so both lines should describe the change as additive.

Non-blocking: the editor's new refusal says no theme rule can replace the selected-row wash, which does not hold for a table with hasRowHighlight={false}, where there is no wash and the suggested token paints nothing (see the inline note), and the earlier header comment suggestion in useTableSelection.tsx still applies. The two new editor tests fail without the editor commit and pass with it, and a theme rule in the selected state recolours the wash in Chromium as the release note says.

Claims and files checked
  • Core release note: a row that useTableSelection selects carries the table-row selected state — verified (useTableSelection.tsx, test "marks only selected rows…").
  • Core release note: a theme styles it with components: {'table-row': {selected: {…}}} — verified (Table.doc.mjs, test "matches a theme's selected table-row rule…").
  • Core release note: the selection wash stays as it was — verified (wash code unchanged; default rendering pixel-identical).
  • Core release note: a theme recolours the wash by setting --color-accent-muted in that state — verified (Chromium).
  • Editor release note: the editor's part data reads the paint Core writes inline for a state, so a selected table row reads --color-accent-muted — verified (_parts.mjs; only the selection module matches in the built Core).
  • Editor release note: how "selected table row light blue" answers with --color-accent-muted … --on table-row --state selected — verified (test passes; fails without the editor commit).
  • Editor release note: a background on a selected table row is refused with that command — verified for the default row highlight (test passes); see the non-blocking note for hasRowHighlight={false}.
  • Description: today a selected row is marked only with aria-selected and an inline wash, and the editor has no selected state to offer — verified against the base.
  • Description: the state is written with the shared theme attribute helper beside aria-selected, removed on unselect, and kept whatever hasRowHighlight is — verified (code and tests).
  • Description: nothing else in the output changes, callers make no new decision, and selection still re-renders only the changed checkbox — verified (diff, unchanged config, passing perf tests).
  • Description: TableRow FR5 names the state as public theme surface, Table FR6 points to it, and the theming-surface rule covers selection on the owning target — verified.
  • Description: theming-target tests, existing selection tests, the knowledge and changeset checks, eslint and prettier pass — verified at this revision, editor files included.
  • Description: writing rubric results — verified.
  • Description scope (Table, TableRow) — narrower than the change, since it does not mention the editor commit; not false.
  • File .changeset/experimental-theme-table-row-selected.md — clear.
  • File .changeset/table-row-selected-state.md — clear.
  • File docs/specs/components/Table/Table.spec.md — clear.
  • File docs/specs/components/Table/TableRow.spec.md — blocking finding above.
  • File packages/cli/api/theme-edit/_check.mjs — non-blocking note.
  • File packages/cli/api/theme-edit/_how-question.mjs — clear.
  • File packages/cli/api/theme-edit/_parts.mjs — clear.
  • File packages/cli/api/theme-edit/theme-edit.test.mjs — clear.
  • File packages/cli/api/theme-edit/theme-how.test.mjs — clear.
  • File packages/core/src/Table/Table.doc.mjs — clear.
  • File packages/core/src/Table/plugins/selection/useTableSelection.test.tsx — clear.
  • File packages/core/src/Table/plugins/selection/useTableSelection.tsx — non-blocking comment suggestion.
  • File packages/themes/probe/src/probeTheme.ts — clear (regenerated fixture; the generator's check reports it current).

Automated review (maintainer link)

Comment thread packages/cli/api/theme-edit/_check.mjs Resolved
The TableRow record's compatibility lines say a selected row gains data-selected="selected" and the table-row target gains the selected state, and its builder impact names the state. The selection hook's header says the same in short sentences. The editor's refusal of a selected table-row background says both cases: by default Core paints it inline from --color-accent-muted, and only where the component is set not to paint it does a selected background apply.
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 14, 2026
@josephfarina

Copy link
Copy Markdown
Contributor Author

/approve-spec b123fcb

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 14, 2026

@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.

Approved pending CI: CI has not finished on this head yet. The selected theme state on table rows, the theme editor's answer for it, and the TableRow record now agree, and the earlier record, comment and refusal-wording notes are all addressed.

Non-blocking: the editor's refusal now says a selected background does apply on a table with its row highlight off, but it still refuses that background and offers only the token command, so editor users with such tables have no route to the setting that works for them (see the inline note).

Claims and files checked
  • Core release note: a row that useTableSelection selects carries the table-row selected state — verified (useTableSelection.tsx, test "marks only selected rows…").
  • Core release note: a theme styles selected rows with components: {'table-row': {selected: {…}}} — verified (Table.doc.mjs, test "matches a theme's selected table-row rule…").
  • Core release note: the selection wash stays as it was — verified (wash code unchanged; default rendering pixel-identical in Chromium).
  • Core release note: a theme recolours the wash by setting --color-accent-muted in that state — verified (the inline wash reads that variable; Chromium shows the recoloured rows).
  • Editor release note: the part data reads the paint Core writes inline for a state, so a selected table row reads --color-accent-muted — verified (_parts.mjs; only the selection module matches in the built Core).
  • Editor release note: how "selected table row light blue" answers with --color-accent-muted … --on table-row --state selected — verified (theme-how.test.mjs).
  • Editor release note: a background on a selected table row is refused with that command — verified (theme-edit.test.mjs); the refusal names the highlight-off exception.
  • Description: before this change a selected row had only aria-selected and an inline wash, and the editor had no answer for a selected table row — verified against the base.
  • Description: the state is written with the shared theme attribute helper beside aria-selected, removed on unselect, and kept whatever hasRowHighlight is — verified (code and tests).
  • Description: nothing else in the output changes, callers make no new decision, and selection still re-renders only the changed checkbox — verified (diff, unchanged config, passing selection and perf tests).
  • Description: TableRow FR5 names the state as public theme surface, Table FR6 points to it, and the theming-surface rule covers selection on the owning target — verified.
  • Description: theming-target tests, existing selection tests, the knowledge and changeset checks, ESLint and Prettier pass — verified at this revision.
  • Description: writing rubric results — verified.
  • Description scope (Table, TableRow) — narrower than the change, since it does not mention the editor commit; not false.
  • File .changeset/experimental-theme-table-row-selected.md — clear.
  • File .changeset/table-row-selected-state.md — clear.
  • File docs/specs/components/Table/Table.spec.md — clear.
  • File docs/specs/components/Table/TableRow.spec.md — clear (compatibility lines now additive).
  • File packages/cli/api/theme-edit/_check.mjs — non-blocking note.
  • File packages/cli/api/theme-edit/_how-question.mjs — clear.
  • File packages/cli/api/theme-edit/_parts.mjs — clear.
  • File packages/cli/api/theme-edit/theme-edit.test.mjs — clear.
  • File packages/cli/api/theme-edit/theme-how.test.mjs — clear.
  • File packages/core/src/Table/Table.doc.mjs — clear.
  • File packages/core/src/Table/plugins/selection/useTableSelection.test.tsx — clear.
  • File packages/core/src/Table/plugins/selection/useTableSelection.tsx — clear.
  • File packages/themes/probe/src/probeTheme.ts — clear (regenerated fixture; the generator's check reports it current).

Automated review (maintainer link)

if (inline)
refuse(
E.ERR_THEME_NO_EFFECT,
`By default Core paints ${inline[0]}'s ${family} when ${s.state} as an inline style from ${inline[1]}, which no theme rule can replace, so set ${inline[1]} on ${inline[0]} when ${s.state} instead; only where the component is set not to paint it (such as a table with its row highlight off) does a ${s.state} ${family} apply, and there ${inline[1]} paints nothing.`,

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: this refusal now says a selected background does apply on a table with its row highlight off (hasRowHighlight={false}, Table FR21), but it still refuses it and offers only the --color-accent-muted command, which paints nothing there. An editor user whose tables all turn the highlight off has no route through set to the setting that works for them. A second run suggestion for that case (or a pointer to where such a background can be written) would close the gap; the sentence is also about 70 words of CLI output.

@josephfarina
josephfarina merged commit b36275e into main Nov 14, 2026
89 checks passed
@github-actions
github-actions Bot deleted the core-tablerow-selected-state branch November 15, 2026 06:04

This branch was successfully deployed

1 active deployment
Preview — b123fcbd Deployed Nov 14, 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. needs:design-review Affects visuals — Design should review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant