Repository navigation
feat(Table): window fixed-height flat tables through useTableRowsVirtualization - #8280
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
eec2985 to
8af7ffe
Compare
e223300 to
62e3e47
Compare
8af7ffe to
fd764ea
Compare
fd764ea to
8ba446d
Compare
62e3e47 to
16eee55
Compare
16eee55 to
ad57643
Compare
8ba446d to
d783e47
Compare
d783e47 to
84fdd06
Compare
ad57643 to
0c8e2cd
Compare
0c8e2cd to
1f31ed7
Compare
84fdd06 to
05d66f4
Compare
05d66f4 to
5b71dda
Compare
There was a problem hiding this comment.
This draft isn't ready for approval yet: the new Table.virtualization prop, the useTableVirtualization hook and the added TablePlugin fields (rowModel, wholeRowOwner, renderState, the transform context argument) have no current spec on main, because module:Table/useTableVirtualization is still draft and component:Table FR16–FR22 with DEC-4/DEC-5 exist only in #7972. An engineering owner needs to approve or reject that flat-data contract as the governing spec; they record the decision by commenting /approve-spec <full head SHA> on this pull request, and the author, as an engineering owner, may do so too. Separately from that decision, these need fixing:
- Appending or removing a single row now re-renders every row of every Table (201 cell renders for one row appended to a 200-row table, against 1 before), and
useTableTreeData-perf.test.tsxfails. - The docs-site build stops because
internal/shadcn-registry/routes.lock.jsonlacks the newhooks/use-table-virtualizationroute. TablePropsis now a union type alias, sointerface … extends TableProps<Row>no longer compiles; keep it an interface or follow the deprecation lifecycle.- At 2,819 changed lines, please move the activation and loading support into #8281 and #8282, where it is used.
[Automated review]
5b71dda to
7c0eb76
Compare
There was a problem hiding this comment.
This draft isn't ready for approval yet: the new Table.virtualization prop, the useTableVirtualization hook and the added TablePlugin fields (rowModel, wholeRowOwner, renderState and the transform context argument) have no current spec on main, because module:Table/useTableVirtualization is still draft and component:Table FR16–FR22 with DEC-4/DEC-5 exist only in #7972. An engineering owner needs to approve or reject that flat-data contract as the governing spec; they record the decision by commenting /approve-spec <full head SHA> on this pull request, and the author may do so if they are an engineering owner. Separately from that decision, these need changes:
- A Table using
useTableSelectionoruseTableStickyColumnsnow re-renders every row when one row is appended or removed (201 cell renders for a 200-row table instead of 1), becauseareRowPropsEqualtreats those plugins as render-context consumers. Table.doc.mjsdescribes-1row totals during incremental loading and activation key rules that only ship in #8282 and #8281.- At 2,699 changed lines, please move the
wholeRowOwner/renderStateprotocol that nothing here reads into the PRs that use it.
[Automated review]
7c0eb76 to
0037da7
Compare
There was a problem hiding this comment.
Approval waits on one engineering-owner decision, and two changes are needed either way. The flat-data Table contract on main covers Table.virtualization, useTableRowsVirtualization, rowModel and the transform context, but not this PR's admission of useTableRowStatus to windowing: the virtualization module record lists selection, sort/filter controls, sticky columns, context menus and row indexing as the supported compositions. An engineering owner (the author may, as one) needs to either approve row status as a supported windowed composition, with the module record naming it, by commenting /approve-spec <full head SHA>, or ask for the row-status rowModel declaration and fixed-height registration to be dropped so those tables fall back.
- The change is 4,686 authored lines with no recorded exception: land the focus-return, dev-warning and scroll-geometry extensions first, or have an engineering owner record an exception for the windowing work.
- The changeset releases the hook, but the PR5/PR6 timing and memory measurements and the Chromium accessibility spec that the virtualization module record requires before release are not in the PR yet.
The focusable-selector copy in focusReturn.ts from the previous revision is fixed.
[Automated review]
73e5476 to
874d460
Compare
There was a problem hiding this comment.
Approval waits on one engineering-owner decision, and two changes are needed either way.
The flat-data Table contract on main covers Table.virtualization, useTableRowsVirtualization, rowModel and the transform context, but not this pull request's admission of useTableRowStatus to windowing. An engineering owner (the author may, as one) records that decision by commenting /approve-spec <full head SHA> once the virtualization module record names row status as a supported composition, or asks for the row-status declaration and registration to be dropped so those tables fall back to full rendering.
Needed before approval:
- Decide row status: the virtualization module record lists selection, sort/filter controls, sticky columns, context menus and row indexing as the supported windowed compositions, so
useTableRowStatus.tsx:271-273needs that owner decision. - Reduce scope: at 4,680 authored lines with no exemption or owner exception, land the shared focus, warning and geometry utilities separately and split out the row-status admission, or have an engineering owner record a size exception for the windowing work.
- Add the release evidence: the changeset releases the hook, but the module record's PR5/PR6 timing and memory targets gate completion and its
verified_bylistsTableVirtualization.a11y.chromium.spec.ts, so add the 1k/10k/100k measurements and that spec, or hold the changeset until they exist.
Two small comment moves are suggested inline; they do not block.
[Automated review]
…eRowIndex numbers from it (#10171) * test(Table): row, cell and wrapper transforms get an immutable context; useTableRowIndex numbers from it (red) Co-authored-by: Humberto Virtudes <[email protected]> * feat(Table): row, cell and scroll-wrapper transforms get an immutable TableRowContext / TableRenderContext; useTableRowIndex numbers from it Table builds one frozen render context per render and one frozen row context per mounted row, and passes them as the optional last transform argument. A plugin declares rowModel; selection, sticky columns and row index declare 'flat'. Per-plugin tracked contexts record index and count reads, so a moved row re-renders only for a plugin that reads its index. useTableRowIndex numbers from logicalIndex through its own cell transform; data is optional. Split from #8280 (the transform-context piece only). Co-authored-by: Humberto Virtudes <[email protected]> * fix(Table): a context read after the transform warns in development; docs say to read during the transform Read tracking sees only reads made while the transform runs. A callback that reads logicalIndex later can see a stale value on a memoized row, so the tracked getters warn once in development outside their plugin's transform, and TableRowContext and the body transforms say to copy values in time. The story and CLI block stop passing data to useTableRowIndex. Co-authored-by: Humberto Virtudes <[email protected]> * chore(changeset): the Table context change names @astryxdesign/cli for the numbered-rows block * fix(useTableRowIndex): a passed data array still orders the numbers; only the no-data form uses the row context Legacy row-index configuration continues: a caller who passes data (a grouped table with its ungrouped rows, a subset view) keeps numbering from that array. useTableRowIndex() numbers from logicalIndex. Co-authored-by: Humberto Virtudes <[email protected]>
874d460 to
a14f758
Compare
There was a problem hiding this comment.
Changes are needed before this can be approved. The flat-data Table contract on main covers the new hook, the virtualization prop and the plugin declarations, so no spec decision is pending.
Blocking:
- Newly live check: in a windowed table every scroll event re-measures every mounted row and cell through the dependency-free layout effect in
useTableWindow.ts(plus two rect reads intableRuntime.ts), whicharchitecture:react-component-runtimeINV18 rules out on a scroll path; validate only when the mounted rows, configuration or content change, and keep the body offset from the last content measurement. - The changeset releases the hook while the PR5 timing and PR6 orphan-viewport targets that the virtualization module record (FR13, DEC-5) makes gate completion still fail, as CI's run of the new release spec shows; fix them or hold the changeset until that spec passes.
Component accessibility contractsfails because the new release spec runs on pull requests despite itsrelease-onlytag, andtest-ui (1/4)fails becauseTableVirtualization.release.htmllacks the copyright notice.- At 5,557 authored lines with no exemption, land the shared focus, warning and geometry helpers, the row-index fix and the release harness separately, or have an engineering owner record a size exception for the windowing work.
- Miss:
BaseTable.tsx:636drops themode === 'data'guardmainhas, so a children-mode Table givencolumnsreportsheaderRowCount: 1to scroll-wrapper transforms without rendering a header row.
The two comment-placement suggestions from earlier rounds still apply and do not block.
[Automated review]
There was a problem hiding this comment.
Changes are needed before this can be approved. The latest commit takes row and cell layout reads off the scroll path, restores the children-mode header count and adds the fixture's copyright notice, and the flat-data Table contract on main covers the new API, so no spec decision is pending.
Blocking:
- Miss: in a windowed table with
useTableRowIndex, the 48 px number column cannot fit "1000", so when row 1,000 mounts the clipped-number check falls back and renders every row (all 10,000 rows and 50,200 cells in the release fixture's 10k corpus, all 100,000 at 100k); size the windowed column for the largest row number and add a release-spec step past row 1,000. - After a text-size or theme change,
useTableWindowre-reads only the body extent and skips rows it already checked, so mounted row numbers clip without the fallback that module PR2 and AR5 require; clearcheckedRowswhenrevisionchanges. - Miss:
test-ui (1/4)failsLayer/sharedContexts.test.tsxbecausetableRowFocus.tsandtableRuntime.tscallcreateContextdirectly; create both withcreateSharedContextfromutils/sharedContext.ts. test-ui (1/4)also failskeyboard/keyboardHeight.test.tsbecause the release fixture now callsviewport.addEventListener('scroll', …); rename the variable or attach the probe another way.- The changeset releases the hook while CI's
Component accessibility contractsjob fails the release spec (supported range-plus-commit 4.1–4.3 ms against 4 ms, supported overhead 2.1 ms against 2 ms), and module FR13 and DEC-5 make the PR5/PR6 targets gate completion; fix them or hold the changeset until the release spec passes. - At 5,793 authored lines with no exemption, land the shared helpers, the row-index fix and the release harness separately, or have an engineering owner record a size exception.
[Automated review]
There was a problem hiding this comment.
Approval waits on one engineering-owner decision, and three changes are needed either way. The latest commit fixes the text-size fallback and both CI guard tests, and CI's release spec now meets every PR5/PR6 target, so the changeset no longer blocks.
Owner decision: useTableRowIndex now widens its number column on every Table whose last row number reaches 1,000 (56 px at 1,000 rows, 72 px at 100,000), including tables that never use Table.virtualization. No current record covers that width, and the Table record says released defaults stay unchanged without the opt-in. An engineering owner records whether it applies to every Table, by commenting /approve-spec <full head SHA> on this pull request or answering the open review question; the author may do so as an engineering owner. Limiting the widening to windowed tables also settles it.
Blocking:
- Windowed tables numbered with
useTableRowIndex()withoutdata, the documented default, still keep the 48 px column, so scrolling a 10,000-row windowed table to row 1,000 renders all 10,000 rows; size the column from the row count Table already knows and cover that case in a test or the release spec. useTableWindownow clearscheckedRowson every geometry revision, and a scroll that mounts a row bumps that revision, so most scroll frames re-read every mounted row and cell (568 row reads against 22 in sixty 20 px frames), which breaksarchitecture:react-component-runtimeINV18; the earlier suggestion to clear on every revision was too broad, so clear the set only on a separate revision for font loads, resizes and class or style changes outside the body rows.- At 5,845 authored lines with no exemption, land the shared helpers, the row-index change and the release harness separately, or have an engineering owner record a size exception.
[Automated review]
There was a problem hiding this comment.
Changes are needed before this can be approved. The windowed Table matches the Table and row-virtualization records, ordinary Tables render unchanged, and typecheck, lint and the Table tests pass on this head.
- Miss: Table now windows rows through its own planner (
useTableWindowandtableWindow.ts, called atBaseTable.tsx:710), butarchitecture:list-windowingINV1 says a Core component that windows a long list uses the one shared private windowing module and keeps no windowing code of its own, so either move the range and gap arithmetic into that shared module and call it from Table, or have an engineering owner amend INV1/DEC-1 so Table's planner can ship first.
Smaller, non-blocking points: every Table now runs interaction-modality tracking through useTableWindow even when it never windows, a Table-level test for typed keys (0 versus '0', null ids) would cover module FR6, and once this PR reaches main the hourly canary publishes the hook before the release evidence in #10659 lands.
[Automated review]
There was a problem hiding this comment.
Approved pending CI: CI has not run on this head yet, because this pull request targets the stack branch below it rather than main; it runs once the pull request is retargeted.
The windowed Table matches the Table and row-virtualization contracts, plans its window through the shared private windowing module, and leaves Tables without virtualization unchanged. The earlier blocking point, Table keeping a window planner of its own, is fixed.
Non-blocking:
- Miss:
TableScrollWrapperasksuseScrollableAreato contain overscroll on both axes and then forcesoverscrollBehaviorY: 'auto'(Table.tsx:241-243); letting the shared hook take a per-axis value such as{inline: 'contain', block: 'allow'}keeps one owner and its writing-mode mapping. - Once this reaches
main, the hourly canary publishes the hook before the timing, memory and accessibility evidence in #10659 lands, so land the stack together or keep that evidence ahead of the canary.
[Automated review]
| }); | ||
|
|
||
| if (hasBlockViewport) { | ||
| viewportProps.style = {...viewportProps.style, overscrollBehaviorY: 'auto'}; |
There was a problem hiding this comment.
Non-blocking (Miss): useScrollableArea already maps each logical axis to its physical axis and writes overscroll-behavior for it. Forcing overscrollBehaviorY: 'auto' here gives the module's "inline contain, block allow" only in horizontal writing modes, and overscroll now has two owners. Letting the hook take overscroll: {inline: 'contain', block: 'allow'} and deleting this block keeps one owner.
There was a problem hiding this comment.
Approved pending CI: CI has not run on this head yet, because this pull request targets the stack branch below it rather than main; it runs once the pull request is retargeted.
The windowed Table matches the Table and row-virtualization contracts, plans its window through the shared private windowing module, and leaves Tables without virtualization unchanged. The earlier blocking point, Table keeping a window planner of its own, is fixed.
Non-blocking:
- Miss:
TableScrollWrapperasksuseScrollableAreato contain overscroll on both axes and then forcesoverscrollBehaviorY: 'auto'(Table.tsx:241-243); letting the shared hook take a per-axis value such as{inline: 'contain', block: 'allow'}keeps one owner and its writing-mode mapping. - Once this reaches
main, the hourly canary publishes the hook before the timing, memory and accessibility evidence in #10659 lands, so land the stack together or keep that evidence ahead of the canary.
[Automated review]
There was a problem hiding this comment.
Approved pending CI: CI has not run on this head yet, because this pull request targets the stack branch below it rather than main; it runs once the pull request is retargeted.
The windowed Table matches the Table and row-virtualization contracts, plans its window through the shared private windowing module, and leaves Tables without virtualization unchanged. This head also drops the row-number column widening, which now ships with the row-index registration in #10658.
Non-blocking:
- Miss:
TableScrollWrapperasksuseScrollableAreato contain overscroll on both axes and then forcesoverscrollBehaviorY: 'auto'(Table.tsx:241-243); letting the shared hook take a per-axis value such as{inline: 'contain', block: 'allow'}keeps one owner and its writing-mode mapping. - Merge this with #10658 and #10659 in one window, as the description says, so the hourly canary does not publish the hook before its timing, memory and accessibility evidence.
- Miss:
TableWindowFallback.test.tsx:158starts in fallback at this head (selection's column is not registered until #10658), so it does not yet cover a windowed table switching to fallback while a row holds focus.
[Automated review]
| // Use stable empty array when no plugins provided | ||
| const plugins = pluginsProp ?? (EMPTY_PLUGINS as TablePlugin<T>[]); | ||
|
|
||
| // Admission is resolved before any section renders. |
There was a problem hiding this comment.
Non-blocking (Miss): this comment is passive, which INV29's style avoids. // Table resolves admission before it builds a section. keeps the same constraint.
There was a problem hiding this comment.
Changes requested: one release-note fix. Everything else in the windowed Table matches the Table and row-virtualization contracts, and Tables without virtualization render as before.
Blocking
- This pull request's Changeset announces
useTableRowsVirtualizationas a feature, but.changeset/core-list-window-module.md("which the package does not export yet. Apps import nothing new.") and.changeset/table-window-controller-internal.md("Nothing renders through them yet; apps import nothing new.") are still pending for the same release, so please delete or reword those two changesets here so the release notes stop contradicting each other.
Non-blocking
TableScrollWrapperstill overridesoverscrollBehaviorYafteruseScrollableAreahas set overscroll for both axes (Table.tsx:262-264); a per-axis overscroll value on the shared hook would keep one owner.- Merge this with #10658 and #10659 in one window, as the description plans, so the hook does not reach a release before its timing, memory and accessibility evidence.
[Automated review]
…ualization Table.virtualization takes the capability from useTableRowsVirtualization and mounts only the rows in the Table-owned viewport, with native rows, full-table aria-rowindex/aria-rowcount and aria-hidden spacer rows. Unsupported content, identity, geometry, a caller scrollWrapper and every plugin without a flat row model fall back to full rendering with one development diagnostic. Adds the hook docs, story and CLI example. This diff was generated with AI assistance (Navi). Tags: ai-generated
There was a problem hiding this comment.
Approved. Table.virtualization with useTableRowsVirtualization matches the Table and row-virtualization contracts, Tables without the prop render as before, and the two contradicting internal Changesets are gone.
Non-blocking
TableScrollWrapperstill overridesoverscrollBehaviorYafteruseScrollableAreahas set per-axis overscroll (Table.tsx:262-264); a per-axis value on the shared hook would keep one owner and follow the writing mode.- The comment at
BaseTable.tsx:553is passive;// Table resolves admission before it builds a section.keeps the same constraint. - The release measurements and the Chromium accessibility spec arrive in #10659, so please merge this with #10658, #10668 and #10659 before the next release ships this Changeset.
[Automated review]
Stack
Row virtualization is split into eight stacked PRs, each under the 2,000-line limit. Each PR's base is the one above it, so review and merge from the top of this list down.
Two record amendments the stack relies on: #10665 (Table adopts the shared list-windowing module first) and #10666 (a windowed row-number column fits its last position).
User need
Product tables with thousands of rows mount every row today. At 10,000 to 100,000 rows that means tens of thousands of DOM nodes, a slow first render and janky scrolling. Builders need a supported way to keep native table semantics while only mounting the rows in view, without handing Table a data slice or a second renderer.
Problem and solution fit
useTableRowsVirtualization({rowHeight, viewportHeight})returns an opaque geometry capability. Passing it toTable.virtualizationmakes Table mount only the rows in its own viewport, plus four overscan rows per side, while the caller keeps the completedata,columnsandidKeyon Table.<tr>/<td>with full-tablearia-rowindexandaria-rowcount; gaps arearia-hiddenspacer rows.scrollWrapper, row status, and any plugin that does not declare a flat row model) falls back to ordinary full rendering with one development diagnostic. The next PR in this stack admits the supported plugins.Current specification
module:Table/useTableRowsVirtualization(authority: current): FR1 to FR13, PR1 to PR7 and the AR evidence rules.Public delta and caller burden
useTableRowsVirtualization(config: UseTableRowsVirtualizationConfig): TableVirtualizationCapability, exported from@astryxdesign/core.Table.virtualization(andBaseTableProps.virtualization).UseTableRowsVirtualizationConfig,TableVirtualizationCapability.Caller decisions: a stable explicit
idKey, arowHeightthat fits single-line content and controls, and a boundedviewportHeight. Nothing else changes for existing callers. This PR carries the feature Changeset (table-fixed-height-windowing, core and CLI) and removes the two internal Changesets from #10656 and #10657, which said the hook was not exported yet, so the release notes do not contradict each other. The hourly canary publishes whatever is onmain, so this PR, #10658 and #10659 merge in one window.Design and alternatives
Table owns identity, geometry and the viewport; the hook only carries geometry. A data-slicing hook, a separate virtual Table component and per-plugin windowing were rejected by the module record, because each splits identity and semantics across owners. Windowing arithmetic comes from the shared private
utils/listWindowmodule (#10656), as the list-windowing record requires; #10665 records Table as its first adopter. Column widths are unchanged here; the windowed row-number width, which depends on the #10666 amendment, is in #10658.Evidence
idKeyfunction keeps0and'0'distinct and stays windowed; a propertyidKeyprojects both to'0', and anullid is invalid, so both fall back with the identity diagnostic.Scope
Testing
--max-warnings=0) on every changed file, andpnpm typecheckinpackages/corepass on this exact head.vitest run --project ui packages/coreat the top of this stack: 20,720 tests pass. The Table, hooks, utils and Chat suites pass on this PR's own head. Four locale time-format tests (DateTimeInput,TimeInput,timeFormat) fail on the local machine's ICU data and pass in CI; they do not touch Table.node scripts/pre-review.mjs --base <the branch below>: 1,718 authored lines.node scripts/api-report/cli.mjsoutput for the Table entries and the ShadCN route lock match the generators.main, that is, after the PRs below it merge.This PR was generated with AI assistance (Navi).