Skip to content

fix(Table): a selected row reflects selected on its table-row target - #10187

Closed
cixzhang wants to merge 3 commits into
mainfrom
lane4/table-row-selected-state
Closed

cixzhang wants to merge 3 commits into
mainfrom
lane4/table-row-selected-state

Conversation

@cixzhang

@cixzhang cixzhang commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

User impact

A theme could not style a selected Table row. useTableSelection paints its wash inline and sets only aria-selected, and themeProps('table-row') published nothing about selection. So a theme could change neither the selected row's text nor its border, and with hasRowHighlight={false} it couldn't tell a selected row apart at all. Now a checked row's table-row target reflects selected (data-selected="selected"), wash or no wash, and the built-in wash is unchanged.

Fixes #5425.

Current specification

  • architecture:component-theming-surface INV6 (current): "Variant, size, selection, disabled, and interaction state are reflected as target capabilities through themeProps." Row selection is reflected on its owning target, table-row.
  • The precedents have the same shape: Item's selected state, and component:CheckboxListItem FR15.
  • component:Table FR21: hasRowHighlight=false removes only the selection wash.

Change

  • useTableSelection: applyRowSelectionStyle writes data-selected="selected" on a checked row beside aria-selected, and removes both on uncheck. This runs whatever hasRowHighlight is, so the wash logic is unchanged.
  • Record: component:Table FR21 adds that a selected row reflects selected on its table-row target (INV6), with or without the wash. Width is unchanged.
  • Docs: Table.doc.mjs lists states: ['selected'] on astryx-table-row.
  • API report: the table-row target and data-selected reflection rows.

Evidence

  • Red first: two new useTableSelection.test.tsx cases fail on main:
    • a checked row has data-selected="selected" and loses it on uncheck;
    • with hasRowHighlight={false}, the row has no wash but still has data-selected.
  • Suites: Table plus themingTargets.test.ts pass (1129), and check:knowledge and check:changesets pass.

Writing rubric results

Record touched: component:Table (FR21).

  • R1 narration: present tense.
  • R2 research: none.
  • R3 evidence: none changed.
  • R4 rejected alternatives: none.
  • R5 change references: none.
  • R6 open questions: none touched.

Owner: fix-loop lane 4. Land path: Drain merges after CodeBunny, Specs and CI.

useTableSelection writes data-selected="selected" on a checked row beside
aria-selected, with or without the built-in wash, so a theme can style a
selected row (architecture:component-theming-surface INV6). Table FR21 and
the table-row target's states record it.
@vercel

vercel Bot commented Nov 6, 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 6, 2026 2:14pm UTC

Request Review

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

astracat-bot Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 6, 2026, 2:20 PM UTC

@github-actions github-actions Bot added needs:spec-owner-review Current knowledge records await owner approval and removed needs:spec-owner-review Current knowledge records await owner approval labels Nov 6, 2026
@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

Current run: The current CI run concluded skipped. 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.

Approved pending CI: CI has not run on this head yet because the pull request is a draft, and marking it ready runs it.

A checked row now reflects selected on its table-row target with the wash on or off, which follows the theming-surface rule that selection state stays on the owning target, and the new component:Table FR21 sentence is approved for this head. Both new tests fail on main and pass here.

  • Optional: the changed comment on applyRowSelectionStyle is one 34-word sentence with two topics; the inline suggestion splits it to fit the repository's comment style.
  • Worth knowing: with the default wash on, its inline background still covers a theme's selected fill, so a theme that wants its own fill also needs hasRowHighlight={false}.

[Automated review]

Comment on lines +153 to +155
* `aria-selected` and the `table-row` target's `selected` state track
* selection on their own: they stay correct whether or not the row is
* painted, so a theme can restyle a selected row with the wash off.

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): this is one 34-word sentence with two topics, and the repository's comment rule asks for at most 25 words and one topic per sentence in a description. A shorter version that keeps only the reason:

 * `aria-selected` and `data-selected` follow selection, not the wash.
 * A theme can style a selected row with the wash off.

@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 run on this head yet because the pull request is a draft, and marking it ready for review runs it.

A checked row now reflects selected on its table-row target with the wash on or off, which follows the theming-surface rule that selection state stays on the owning target, and the new component:Table FR21 sentence is approved for this head. Both new tests fail without the fix and pass here, and the Table suite still passes after the merge from main.

  • Optional: the changed comment on applyRowSelectionStyle is one 34-word sentence with two topics; the open inline suggestion splits it to fit the repository's comment style.
  • Worth knowing: with the default wash on, its inline background still covers a theme's selected fill, so a theme that wants its own fill also needs hasRowHighlight={false}.

[Automated review]

@cixzhang

Copy link
Copy Markdown
Contributor Author

(Posted by Cindy's agent.) Closing as superseded by #11729 (b36275e), which is on main. A row that useTableSelection selects now carries the table-row target's selected theme state (data-selected="selected"), whatever hasRowHighlight is. That is this PR's change.

main also has everything else this PR added:

  • the behavior: component:TableRow FR5;
  • the selected-state tests, including hasRowHighlight={false}: useTableSelection.test.tsx;
  • states: ['selected']: Table.doc.mjs.

Nothing here remains to carry.

@cixzhang cixzhang closed this Nov 18, 2026
@github-actions
github-actions Bot deleted the lane4/table-row-selected-state branch November 19, 2026 06:04

This branch was successfully deployed

1 active deployment
Preview — e351c6fb Deployed Nov 6, 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.

Table: a theme cannot key off row selection — themeProps('table-row') publishes no selected state

1 participant