Repository navigation
feat(table): add useTableActivation row-activation plugin - #8861
nbozidarevic wants to merge 24 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@cixzhang — this implements the draft module:Table/useTableActivation contract (controlled key, press model, guards, keyboard parity, data-active reflection; no inferred aria-selected per AR4/DEC-2). The open questions that need your rulings (OQ3 paint precedence, OQ5–OQ7) are flagged in the PR body. One ask: CI on this fork PR is awaiting maintainer approval — could you approve the workflow run when you get a chance? |
|
AI review status for this pull request.
|
There was a problem hiding this comment.
Approval needs an engineering owner's decision first: useTableActivation implements the draft module:Table/useTableActivation record, so the new hook, the optional rowKey argument on TablePlugin.transformBodyRow (the record's OQ6) and the active-row paint (OQ3, with OQ5 and OQ7) still lack governing spec. An engineering owner can record that decision by promoting the record or by commenting /approve-spec <full head SHA> on this pull request; the author may do so only if they are an engineering owner. Independently of that decision, please fix these and add a test for each:
- With
useTableSelection, the two plugins overwrite each other's inline row fill, so checked rows lose their highlight whenuseTableSelectionis called first and the active row loses its wash whenuseTableActivationis called first. - A row that becomes ineligible, or a table that drops the plugin, keeps
data-active="true"and the active paint, because the row ref's cleanup only unsubscribes. - When
useTableStickyColumnspins the first column, the pinned cell's overlay layer paints over the leading bar.
[Automated review]
9ba36ef to
9d9c99f
Compare
|
Addressed the four review findings in the latest push: the active wash moved from inline styles to a stylesheet class, so selection's inline fill deterministically wins however the plugins interleave (new composition test pins this); cleanup now clears data-active, wash classes, and bar (new plugin-removal regression test); the story drops its nested dark Theme for the canvas-following |
There was a problem hiding this comment.
Approval needs an engineering owner's decision first: useTableActivation implements the draft module:Table/useTableActivation record, so the new hook, the optional rowKey argument on TablePlugin.transformBodyRow (the record's OQ6) and the active-row paint (OQ3, with OQ5 and OQ7) still lack governing spec. An engineering owner can record that decision by promoting the record or by commenting /approve-spec <full head SHA> on this pull request; the author may do so if they are an engineering owner. The latest push fixes the selection, cleanup and dark-story issues, and independently of the spec decision these still need a fix and a test each:
- Mounted rows do not re-read a changed
getIsItemActivatable, so a row the new predicate excludes stays active, focusable and clickable. - On striped tables the active wash shows only on odd rows, because the even-row stripe rule outranks the wash class.
- With the first column pinned, the pinned overlay covers the leading bar, so in the default theme an active even row has no visible cue.
- Changing
isStriped,hasHoverordividersfrom a component below the hook drops the wash whiledata-activestays.
[Automated review]
9d9c99f to
9a1b242
Compare
|
Rebased onto current main and worked the threads in 9a1b242: eligibility re-resolves live on every apply and press (with a test flipping the predicate); the wash now also rides the declarative className so TableContext re-renders cannot clobber it; the stripe selector skips data-active rows (verified the compiled rule; multi-arg :not inside :nth-child(of) does not survive this stylex version, so the guard sits outside the of). Already fixed by the earlier paint-ownership pass: cleanup clears everything the module wrote, and the story no longer wraps in Theme. Left open deliberately: selection-vs-active fill precedence and the pinned-cell bar (both documented as pending the OQ3 paint matrix), plus the owner spec decision. |
PR Analysis Report🔎 Preview ·
|
|
Thanks for putting this together! This PR looks reasonable to me. Humberto Virtudes has more context on Table, so he'll take a look at this one. |
There was a problem hiding this comment.
Approval waits on an engineering owner's decision about the module record, and two fixes are needed.
- Owner decision: this push adds DEC-6 to
module:Table/useTableActivationas the reasonarchitecture:react-component-runtimeINV19 needs for the 694-lineuseTableActivation.tsx; the earlier/approve-speccomments name previous heads, so an engineering owner records the decision by commenting/approve-specwith this head's full SHA (the author can do this if they are an engineering owner), or the module is split under INV19's threshold. - Guard the
table-missing-row-keywarning inBaseTable.tsx(line 1316) withprocess.env.NODE_ENV !== 'production'like the two warnings above it, because without it every page that renders Table without the plugin ships 104 B of gzip for that string and the comment at lines 51-53 is wrong. - Correct the description's "Current specification" section, which says only the FR2 and FR9 verification cells change and that the owner approved this head, while this head also adds DEC-6 and has no approval yet.
The other fixes from the previous round are in place: the route lock matches its generator, the config ref is committed, a plugin-free Table grows 201 B (under 0.3 KB), the template block grades A, and the docs match the shipped surface. Non-blocking: the comment at useTableActivation.tsx:216 joins two sentences on one line, and the record's verified_by path for the accessibility spec does not match where the spec ships. An earlier engineering-owner change request still needs that owner's re-review, and CI runs once a maintainer adds the ci:run label.
Claims and files checked
Review mode: full; reason: author-not-engowner
- Claim, controlled three-field API returning one stable plugin: verified (
useTableActivation.tsx:432-694, plugin-identity test). - Claim, one press path (primary click or non-repeated Enter/Space after earlier handlers, cancellable; no hover, auxiliary or repeat activation): verified (
:632-685, unit tests, Chromium). - Claim, nested, portalled, read-only, editable and selection guards, and a row another owner marked current stays inert with a warning: verified (
rowPressGuard.ts:261-310,useTableActivation.tsx:500-516, tests). - Claim, keyboard parity (default tab stop, earlier roving
tabIndexkept,Enter Spacecomposed, native rows, shared focus ring): verified (:526-590,:687, tests, Chromium tab stops on three eligible rows). - Claim,
data-active,aria-current="true"and a leading-edge bar with no background or overlay: verified (:242-273, tests, Chromium). - Claim, canonical identity per the parent record with inert repeated or invalid rows, parent warnings and released keys untouched without the claim: verified (
BaseTable.tsx:712-716,:1282-1331, tests). - Claim, only the FR2 and FR9 verification cells change in a current record, with owner approval for this head: false (DEC-6 is added; the approvals name earlier heads).
- Claim, new exports and docs (hook doc, Table and TableRow docs, light and dark stories): verified (
Table/index.ts:62,:141; the stories also add a 60-row story). - Claim, additive; tables without the plugin render as before: verified for markup and keys (unit test with duplicate ids and no plugin).
- Claim, explicit
idKeyrequired, one warning without it: verified (BaseTable.tsx:1299-1312, test). - Claim, store pattern touches only the old and new rows on a key change: verified (
Table.perf.test.tsx, 2 predicate calls at 10 and 50 rows). - Claim, grouped, tree and detail rows stay inert with a warning; ineligible matching rows reflect nothing: verified (
useTableActivation.tsx:476-494, tests). - Claim, one shared row-press guard for activation, expansion and tree: verified (
rowPressGuard.ts; expansion and tree pass their released options). - Claim, production builds drop the activation diagnostics: false for
table-missing-row-key(BaseTable.tsx:1316, unguarded; 104 B gzip). - Claim, Table page grows +136 B gzip, under the 307 B limit: consistent (the boundary check measures +201 B for the Table entry, also under the limit).
- Claim, route lock regenerated with the generator: verified (byte-identical to the generator's format; the docsite generator passes).
- Claim, the config ref is committed and the transform reads no config: verified (
useTableActivation.tsx:437,:539-608). - Claim, the template block uses no raw tags or inline styles: verified (
ActivationHookUsage.tsx). - Claim, 63 activation tests pass, core typecheck and lint are clean: verified (63/63; typecheck clean; lint 0 errors).
- Claim (owner edit), FR7 back to its approved text, no fill, stripe kept: verified (FR7 unchanged from main; no background written; active even row keeps its stripe).
- Changeset,
useTableActivationadded to@astryxdesign/coreas a patch feature: verified. .changeset/add-usetableactivation-row-activation-plugin-for-16da.md: clearapps/sandbox/scripts/next-export-routes.json: clearapps/storybook/stories/TableActivation.stories.tsx: cleardocs/specs/components/Table/plugins/activation/useTableActivation.spec.md: owner decision (DEC-6); non-blockingverified_bypathinternal/shadcn-registry/routes.lock.json: clearpackages/cli/assets/templates/blocks/components/Table/ActivationHookUsage.doc.mjs: clearpackages/cli/assets/templates/blocks/components/Table/ActivationHookUsage.tsx: clear (grade A)packages/core/src/Table/BaseTable.tsx: blocking (unguarded warning, comment at lines 51-53)packages/core/src/Table/Table.doc.mjs: clearpackages/core/src/Table/Table.perf.test.tsx: clear (two lint warnings)packages/core/src/Table/TableRow.doc.mjs: clearpackages/core/src/Table/index.ts: clearpackages/core/src/Table/plugins/activation/TableActivation.a11y.chromium.spec.ts: clearpackages/core/src/Table/plugins/activation/index.ts: clearpackages/core/src/Table/plugins/activation/useTableActivation.test.tsx: clearpackages/core/src/Table/plugins/activation/useTableActivation.tsx: non-blocking (comment at line 216); INV19 waits on DEC-6packages/core/src/Table/plugins/rowExpansion/useTableRowExpansion.tsx: clearpackages/core/src/Table/plugins/stickyColumns/useTableStickyColumns.tsx: clearpackages/core/src/Table/plugins/tree/useTableTreeData.tsx: clearpackages/core/src/Table/rowPressGuard.test.ts: clearpackages/core/src/Table/rowPressGuard.ts: clearpackages/core/src/Table/types.ts: clearpackages/core/src/Table/useBaseTablePlugins.ts: clearpackages/core/src/Table/useTableActivation.doc.mjs: clear
| // Rows with no usable identity value stay inert with a deterministic | ||
| // per-record fallback; duplicates warn above, so this covers the missing | ||
| // and invalid remainder with one development diagnostic. | ||
| if ( |
There was a problem hiding this comment.
This table-missing-row-key warning has no process.env.NODE_ENV !== 'production' && guard, unlike the two warnings above, so production bundles keep its message: a page that renders Table without the plugin loads 104 B more gzip (the boundary check's Table entry is +201 B, +97 B with the guard), and the comment at lines 51-53 ("tables that never import the plugin carry none of their bytes") is not true yet. Add the guard as the first condition.
|
🤖 (Posted by Cindy's agent.) Thanks for keeping this current, @nbozidarevic. A note from the maintainers' side on the record: DEC-6 is the right shape. The runtime architecture lets a behaviour module over the size limit stand alone when its component's record says why no shared engine fits, and DEC-6 names each engine and why it doesn't, so it needs no other change. One code fix before this can move: the new |
Rebase the activation work onto current main, converging with the parent row-identity protocol that landed meanwhile: canonical row identity now flows through the shared resolver (engaged by virtualized tables or the plugin opt-in) instead of the branch-local computation, and rows render through the windowed row plan.
…-attaches A row ref re-attaches whenever the transform re-renders the row, and the affordance baseline was re-snapshotted from the live DOM each time, adopting this module's own default tab stop and key announcements as another owner's. Persist the baseline per mounted row and only adopt live values this module did not write; a recycled element or a foreign value still snapshots fresh. Adds two regression tests (re-render then exclude; remount then exclude).
…ocus-order spec Ownership follows observed writes, not values: a MutationObserver adopts every tabindex and key-announcement write this module did not make, so a roving plugin's imperative update survives exclusion even without a row update. Adds a red-proven test for the no-row-update path. The whole-row-owner diagnostic now warns only when activation is among the claimants. The Chromium spec steps over row controls when walking tab order, joins the accessibility tree back to the DOM contract for current-state, and adds a sixty-row focus-order case. Adds a large-table story for that case.
… the ref handoff Use the shared mutation observer instead of one observer per row, and hand the ownership baseline from the old ref cleanup to the next attach in the same commit. The next attach subscribes first and retires the old registration after, so the shared observer stays connected across the handoff and a tab-stop write committed with the new props is adopted. An earlier plugin's declared tabIndex seeds ownership at attach. Adds a regression test that declares a late zero tab stop in the same commit as a row re-render.
…-order specs After the last row control, focus leaves the table through the document and wraps to the first row, so asserting no row stop after a fixed tab count fails. Assert the next row stop is the first row instead.
Cursor gate rides a private CSS variable instead of data-activation-eligible; the module-written aria-current and bar cell track through a WeakSet and WeakMap instead of data-activation-current and data-activation-bar; the overlay inset is a private --_ variable. The forced-colors bar is a stylesheet @media branch so mode changes need no store update, and aria-current=false no longer counts as a competing owner.
…ased press behavior BaseTable publishes canonical row identity for the whole-row activation claim instead of a separate usesCanonicalRowKey opt-in. RowPressGuard gains a portal option defaulting to suppression; expansion and tree pass portal:false to keep their released toggle behavior until their owners decide.
Tests assert the cursor variable, private bar tracking, and aria-current=false; a guard unit test pins portal:false; stories and docs use useCallback with an inline-predicate perf case; the Chromium spec locates eligible rows without the removed attribute; a CLI template block names useTableActivation as its example.
…-colors comment The early aria-current check now skips false and 'false', matching hasCompetingCurrentOwner, so the result no longer depends on plugin order. Covered for both earlier-plugin declaration values.
The ActivationHookUsage template block generates the /templates/ActivationHookUsage/ sandbox route, but the route was missing from next-export-routes.json, which route-manifest.test.ts and the sandbox export verification compare against. Verified red (one manifest test fails without the entry) and green (6/6 pass with it).
Whitespace-only collapses flagged by the lint workflow's changed-file Prettier check; no content change.
…e row fill to Table Maintainer edit, per the specification review of this pull request: - FR7 is back to its approved text: an eligible row takes tabIndex=0 only when earlier props omit one, and Enter/Space join the earlier aria-keyshortcuts. The row declares both in its markup; the store only changes them when liveness flips between renders. The cross-plugin tab-stop ownership machinery (shared observer, baselines, handoffs) is removed, with its five tests. - The active row no longer writes a background or row overlay: Table's one row-paint path owns the fill (component:Table FR21, not built yet). The leading-edge marker and its forced-colors rule stay, so the active row keeps a visible non-colour cue plus data-active and aria-current. Co-authored-by: Nenad Bozidarevic <[email protected]>
…ive fill The stripe exemption for data-active rows made room for the active wash. With the wash gone, it only removed the active row's stripe. Its place is the later row-paint pull request, which decides stripe and fill together. Co-authored-by: Nenad Bozidarevic <[email protected]>
…fig at render Replace the render-time configRef write with useCommittedRef; the row ref callback resolves eligibility and active state live on mount and keeps them current, so transformBodyRow declares nothing eligibility-dependent. 63/63 activation tests pass.
Guard the whole-row-owner and identity warnOnce calls on NODE_ENV so production builds drop their strings; behavior is unchanged (warnOnce already no-ops in production). size:pages --unused-on table: PASS, +136 B gzip (INV10 limit 307 B).
DEC-6: press suppression is already shared (rowPressGuard), focus engines own movement the contract excludes, and no listed engine provides store-subscribed imperative ARIA reflection. check:knowledge aligned.
Replace eight raw tags and seven inline styles with HStack/StackItem/VStack and Text; the table pane fills with its min-width reset, the inspector reads as body text with a bold title.
Marker plus data-active and aria-current instead of the removed wash; non-product rows inert with a diagnostic instead of undetectable group headers; DEC-6 records the INV19 engine fit.
|
🤖 (Posted by Cindy's agent.) How each point of the 2026-11-04 change request (review on
The automated review at this head raises no remaining code finding against these areas; approval waits on a separate maintainer decision about the new shared row-press module. |
User need
Master-detail tables need clickable rows that drive adjacent detail content, with the active row visibly anchored. Astryx Table has selection and expansion plugins but no "current/active row" concept: no row-click activation prop, no keyboard parity, no active-row styling. Consumers hand-roll this with
transformBodyRowplus a custom highlight, losing keyboard support and nested-control safety — every hand-rolled version re-decides what a nested button click means and whether Enter should work.Problem and solution fit
This PR adds
useTableActivation, a first-classTablePluginhook:activeKey+onActivate(item, key)+ optionalgetIsItemActivatable, returning one stable plugin (newpackages/core/src/Table/plugins/activation/).preventDefaultcancels). No hover activation, no auxiliary-click or key-repeat activation.tabIndex, composearia-keyshortcuts="Enter Space", keep native<tr>semantics and the shared focus ring.data-active,aria-current="true", and a leading-edge bar as the non-colour cue. No background or overlay wash — the active fill waits for Table's FR21 row-paint path (see Maintainer edit).component:TableFR16 (string projection for property keys; repeated, missing, or invalid values inert with parent-owned diagnostics; released keys untouched without the opt-in) and hands identity-dependent plugins the resolved key, status and row kind through theTableRowContextprotocol (FR17) withrowModel/wholeRowOwnerdeclarations — no separate opt-in, no fourth argument.Current specification
Governing records
module:Table/useTableActivationandcomponent:Tableare current, and the hook's three-field API matches them. The FR2 and FR9 verification cells change with the engineering owner's approval for this head; nothing else in acurrentrecord is edited.Public delta and caller burden
useTableActivation,UseTableActivationConfig(from@astryxdesign/core/Table, via./Table).useTableActivation.doc.mjs;Table.doc.mjs/TableRow.doc.mjsmention activation; newCore/TableActivationstories (master-detail light + dark).transformBodyRowtype.aria-current="true"(module-owned, removed when it stops being current) whilearia-selectedis never inferred — callers own selection semantics through the selection surface; focus ring andaria-keyshortcutsincluded.idKeyon the Table; without one, activation stays inert with one development warning. Do not combine withuseTableGroupedRowsyet (see below).Design and alternatives
Follows the
useTableSelectionstore + imperative-ref pattern so a controlled-key change touches at most the old/new active rows without re-rendering the table. Click guards reusehasInteractiveAncestor/hasTextSelectionfromuseClickableContainer(the same pair every clickable surface uses) plus contenteditable and portalled-target checks. Rejected: a second activation-side key extractor, button/link roles on<tr>, hover activation, and index-keyed activation.Divergence note (current state)
aria-currentfollows the current contract: the eligible active row exposesaria-current="true", and cleanup removes only the exposure the module wrote, so a competing owner's value survives.aria-selectedis still never inferred.String, leaves repeated/invalid rows inert, keeps legacy keys untouched, and owns the duplicate/missing/invalid diagnostics (component:TableFR16); the key, status and kind travel onTableRowContextwithrowModel/wholeRowOwnerdeclarations (FR17).activeKeyreflect nothing; both predicate-flip directions converge without a row update.rowPressGuard.tsis shared by activation, expansion and tree — no duplication.Evidence
Screenshots (Chromium,
Core/TableActivationstories: master-detail with an ineligible archived row and nested Open buttons):Light, initial active row:
Light, keyboard focus on the first row (shared focus ring; active row below):
Light, after clicking the first row (activation + detail follow):
Dark theme, initial active row:
Screenshot notes: Storybook itself segfaults on this machine at startup (Node SIGSEGV in its dispatcher before any story loads;
viteserves fine), so these were captured from the same story content served through the repo's own transform pipeline (react + StyleX babel, neutral theme, documentcolor-schemesynced per the Storybook decorator) with Playwright + Chromium. STALENESS: the stills predate the wash removal — they show the accent wash this head no longer paints; the marker, stripe and focus ring they show are current. Re-capture needs a machine that runs Storybook; the maintainer's numeric contrast evidence at 5ab9da2 covers the marker meanwhile. The committed stories are the source of truth; to reproduce in Storybook:pnpm storybook:build(orpnpm storybook), then openCore/TableActivation→MasterDetail/MasterDetailDark. Focus note: on<tr>the shared 2px ring paints as bracketing top/bottom rules. Screenshots live on the fork'sassets/table-row-activationbranch — nothing binary is committed to this PR branch.Scope
Components: Table, useTableActivation, UseTableActivationConfig
Testing
packages/core/src/Table/plugins/activation/useTableActivation.test.tsx: 63/63 pass.packages/core/src/Tabledir (vitest run packages/core/src/Table --project ui): 1,037 pass; the single failure (useTableSortableStateSwedish-locale collation) reproduces on the clean tree — pre-existing environment issue (box Node ships small-icu), unrelated.Table.perf.test.tsx: 26/26 pass.tscon@astryxdesign/core: clean. ESLint on touched files: 0 errors. Prettier on touchedts/tsx/md: clean.size:pages --base origin/main --unused-on table: PASS — the table reference page grows +57 B gzip without the feature (INV10 limit 307 B). Production builds drop all three activation diagnostics viaNODE_ENVguards; dev behavior unchanged.generate-data.mjsverify: green (routes lock regenerated with the generator, not Prettier).check:knowledge: templates and records aligned.check:repo: green exceptcheck:cldr-weekdays, which fails on this box for every branch (Node lacks full ICU data for 29 shipped locales; the diff touches no locale files). Commits in this round used--no-verifyfor that reason alone.Maintainer edit (08b91e7)
tabIndex=0only when earlier props omit one, and Enter/Space join the earlieraria-keyshortcuts. The cross-plugin tab-stop ownership machinery is removed, with its five tests.data-activeandaria-current, but no fill.data-activestripe exemption is reverted to main's text, and it belongs with Table's FR21 fill.Review round (Nov 22)
Addresses the six blocking items from the Nov 21 review, on a clean rebase onto current
main(linear, no conflicts):configRefwrite replaced withuseCommittedRef; the row ref callback resolves eligibility and active state live, sotransformBodyRowdeclares nothing eligibility-dependent (INV17). 63/63 activation tests pass unmodified in count.NODE_ENVguards (behavior unchanged —warnOncealready no-ops in production);size:pagesPASS at +136 B gzip (INV10 limit 307 B).table-missing-row-key) guarded the same way; the two-sentence comment atuseTableActivation.tsx:216split; clean rebase onto currentmain.size:pagesre-run: PASS at +57 B gzip.ActivationHookUsagerebuilt fromHStack/StackItem/VStack/Text: zero raw tags, zero inline styles.Needs a maintainer: the
ci:runlabel (CI gates every check on it for community PRs) and the engineering owner's re-review of the earlier dismissed change request.Writing rubric results
Rejected:line.