Skip to content

feat(Table): useTableRowsVirtualization's viewportHeight becomes initialViewportHeight, which no longer sizes the Table - #10894

Merged
cixzhang merged 6 commits into
mainfrom
feat/table-initial-viewport-height
Nov 10, 2026
Merged

cixzhang merged 6 commits into
mainfrom
feat/table-initial-viewport-height

Conversation

@cixzhang

@cixzhang cixzhang commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Builder impact

useTableRowsVirtualization({rowHeight, viewportHeight}) becomes useTableRowsVirtualization({rowHeight, initialViewportHeight}). Both stay required. The hook has shipped only in canary builds (the latest stable Core, 0.7.11, doesn't have it), so it's renamed before its first stable release, with no alias.

- useTableRowsVirtualization({rowHeight: 48, viewportHeight: 480})
+ useTableRowsVirtualization({rowHeight: 48, initialViewportHeight: 480})

Behavior

  • initialViewportHeight only seeds the first window, on the server and in the first client frame (ceil(initialViewportHeight / rowHeight) + 4 rows). After mount the measured viewport sets the window, as before.
  • The Table takes its height from its parent. A windowed Table's scroll area no longer gets height/maxHeight from the prop. It takes height: 100%; min-height: 0, so a fixed-height parent, or a flex child with min-height: 0, bounds it.
  • A parent that gives no height: the scroll area is as tall as its content and every row renders, with no warning. One test pins this, and the docs say: give the Table's parent a height, fixed or relative, or a flex child, so windowing can bound the rows.
  • In a sized Card: the windowed scroll region bleeds over the Card's block padding at its first and last edges, and its height adds that padding back, so it ends at the Card's bottom edge whose corner it takes. A Chromium proof checks it at 400px.
  • rowHeight and the validation are unchanged.

Records and docs

  • module:Table/useTableRowsVirtualization: the public contract, builder impact, Geometry concept, the API section and FR10's seed formula use initialViewportHeight, which seeds only the first window. The owner row comes from Specs.
  • component:Table FR19: the block size is the height the parent gives.
  • Hook and Table docs (.doc.mjs), the CLI example block, the Storybook story, api-report.md, and the original feature Changeset now use the new name. The example and the story put the Table in a 320px-tall stack. A new Changeset records the rename and the sizing rule.

Evidence

  • Product source vs main: 4 files, a small rename plus the block-size style.
  • TableWindowedCard.a11y.chromium.spec.ts: in a 400px Card, the region's inset is the same at the top and bottom, and it still windows.
  • useTableRowsVirtualization.test.tsx:
    • initialViewportHeight: 240 seeds 9 rows and sets no height on the scroll area, which takes height: 100%.
    • One parent-height test: with a sized parent the Table windows; with a parent that gives no height, every row renders.
    • initialViewportHeight: 0 falls back to rendering every row.
  • The Table suite (42 files) and sharedBrands pass, along with core tsc, ESLint, Prettier, check:changesets and check:knowledge. The heavy legacy render-cost test times out under full-suite load on a laptop and passes alone.
  • The Storybook story that the Table virtualization a11y browser spec opens sits in a 320px parent, so it still windows.

Credit: the Table virtualization stack, its window controller and the list-windowing module are Humberto Virtudes's (@humbertovirtudes). This changes only the hook's viewport input. The final design here (a required initialViewportHeight that only seeds the first window, the Table's height from its parent's layout, and no warning) differs from his original, in which viewportHeight also set the scroll area's height.

Scope

Components: Table, UseTableRowsVirtualizationConfig

  • One public API change, per the virtualizer vocabulary decision; no other virtualizer is renamed.
  • Public text contains no internal Meta context.

Writing rubric results

  • Present tense, describes the system: yes.
  • No history, pull requests or research in the record: yes.
  • Owner routing: the viewport input stays in module:Table/useTableRowsVirtualization.
  • One topic per sentence: yes.

@vercel

vercel Bot commented Nov 9, 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 10, 2026 5:48am UTC

Request Review

@astracat-bot

astracat-bot Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🔄 In progress (for maintainers only) Nov 10, 2026, 6:05 AM UTC

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 9, 2026
@cixzhang cixzhang added the ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) label Nov 9, 2026
@github-actions github-actions Bot added the needs:design-review Affects visuals — Design should review label Nov 9, 2026
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 9, 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.

Approval waits on an engineering owner's decision on the module:Table/useTableRowsVirtualization record change, and three fixes are needed whatever that decision is.

This pull request intentionally rewrites FR10 and the required viewportHeight Geometry row of that current record. An engineering owner records the decision by commenting /approve-spec <full head SHA>, and the author may do so as an engineering owner. The decision to settle is whether initialViewportHeight keeps fixing the viewport's height after the first frame, as this head does, or is read for the first frame only, as the draft architecture:list-windowing DEC-6 in #10796 says.

Required changes:

  • With initialViewportHeight omitted and a parent that has no height, the scroll wrapper's height: 100% resolves to auto, so in Chromium all 2,000 of 2,000 rows mount while the Table stays windowed and no development diagnostic runs (Table.tsx:135-138); please detect that unbounded viewport, fall back with a diagnostic, and add a browser test.
  • The initialViewportHeight JSDoc says the value is for the first frame and that the measured viewport wins after mount, but Table.tsx:266-267 keeps the viewport's height and max-height at that value, so please align the JSDoc, or the behaviour, with the owner's decision.
  • UseTableRowsVirtualizationConfig.viewportHeight (removed) and UseTableRowsVirtualizationConfig.initialViewportHeight (added) are outside this pull request's scope (Table): name them in the scope with a Components: line under ## Scope and get an owner decision, or split them into their own pull request.

A declared height renders exactly as before in Storybook, and the Table tests, typecheck and lint pass.

[Automated review]

Comment thread packages/core/src/Table/Table.tsx Resolved
@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 5e07e04

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
TableBody 3.5 kB (0) · 3.3 kB CSS (0) — ✓ · ✓ · ✗
TableFooter 3.5 kB (0) · 3.3 kB CSS (0) — ✓ · ✓ · ✗
TableHeader 3.5 kB (0) · 3.3 kB CSS (0) — ✓ · ✓ · ✗
8 more components
Component Size LoC Visual · A11y · RTL
TableRow 7.0 kB (0) · 4.0 kB CSS (0) — ✓ · ✓ · ✗
Table 125.7 kB (+52 B) · 18.4 kB CSS (+79 B) — ✓ · ✓ · —
Markdown 188.5 kB (+46 B) · 20.7 kB CSS (+82 B) — — · — · —
lab/CommentThread 345.3 kB (+45 B) · 2.4 kB CSS (0) — — · — · —
lab/Comments 352.3 kB (+40 B) · 2.5 kB CSS (0) — — · — · —
TableCell 110.3 kB (0) · 17.9 kB CSS (0) — ✓ · ✓ · ✓
TableHeaderCell 109.9 kB (0) · 17.7 kB CSS (0) — ✓ · ✓ · ✓
TableSelectionToolbar 70.7 kB (0) · 13.2 kB CSS (0) — ✓ · ✓ · ✓

Package size:

  • @astryxdesign/cli 3.54 MB packed (+173 B); no new dependencies
  • @astryxdesign/core 7.23 MB packed (+602 B); no new dependencies

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

Committed API report behind this build: cli 29 rows, core 36 rows; run pnpm api:report.

2 API changes (advisory)
Package Where Signature Usage
+ core . · Types · interface UseTableRowsVirtualizationConfig initialViewportHeight: number import type {UseTableRowsVirtualizationConfig} from '@astryxdesign/core'; const x: UseTableRowsVirtualizationConfig = {initialViewportHeight: …}
− core . · Types · interface UseTableRowsVirtualizationConfig viewportHeight: number import type {UseTableRowsVirtualizationConfig} from '@astryxdesign/core'; const x: UseTableRowsVirtualizationConfig = {viewportHeight: …}

Touched components checked; add ci:run-visual or ci:run-rtl to run the full suites.


Generated by PR Enrichment workflow | View full report

@cixzhang cixzhang changed the title feat(Table): useTableRowsVirtualization's viewportHeight becomes the optional initialViewportHeight feat(Table): useTableRowsVirtualization's viewportHeight becomes initialViewportHeight, which only seeds the first window Nov 9, 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.

Approval waits on an engineering owner's decision on the module:Table/useTableRowsVirtualization record change, and two fixes are needed whatever that decision is.

This pull request intentionally rewrites FR10, the Geometry row, the Builder impact and the Public contract of that current record, so that initialViewportHeight only seeds the first window and the Table takes its height from its parent. An engineering owner records the decision by commenting /approve-spec <full head SHA> on this pull request, and the author may do so as an engineering owner.

Required changes:

  • component:Table FR19 still says windowing has "a bounded block size", but under a parent with no height this head keeps the Table windowed at its full content height (112,038px for 2,000 rows in Chromium), so please amend FR19 in this pull request or take the full-render fallback in that state.
  • UseTableRowsVirtualizationConfig.viewportHeight and UseTableRowsVirtualizationConfig.initialViewportHeight (UseTableRowsVirtualizationConfig) are outside this pull request's scope (Table): name them in the scope and get an owner decision, or split them into their own pull request.

The earlier JSDoc mismatch is fixed, a parent with no height now gets one development warning, and the windowing story renders exactly as before; the docs should also say that the Table fills its parent's whole height, so a heading beside it overflows the parent.

[Automated review]

Comment thread packages/core/api-report.md Resolved
@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 10, 2026
@cixzhang
cixzhang marked this pull request as draft November 10, 2026 02:32
@cixzhang
cixzhang marked this pull request as ready for review November 10, 2026 02:32

@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's lint, typecheck and test jobs have not run on this head yet.

An engineering owner approved the rewritten module:Table/useTableRowsVirtualization record and component:Table FR19 at this head, and the earlier FR19 and scope findings are fixed. The new tests fail on main and pass here, and in Chromium a windowed Table fills its sized parent, fits beside a heading in a flex column, and renders every row under an unsized parent.

  • Miss: (non-blocking) the "no height limit" warning fires only when the table has more rows than the first window (useTableWindow.ts:284), while FR19 and the module record say every unsized parent gets it, so please align that wording or drop the row-count condition.

[Automated review]

@cixzhang cixzhang changed the title feat(Table): useTableRowsVirtualization's viewportHeight becomes initialViewportHeight, which only seeds the first window feat(Table): useTableRowsVirtualization's viewportHeight becomes initialViewportHeight, which no longer sizes the Table Nov 10, 2026
@cixzhang
cixzhang marked this pull request as draft November 10, 2026 03:08
@cixzhang
cixzhang marked this pull request as ready for review November 10, 2026 03:08
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 10, 2026
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 33be261

@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's lint, typecheck and test jobs were skipped at this head and have not run on it yet.

An engineering owner approved the rewritten module:Table/useTableRowsVirtualization record and component:Table FR19 at this head. The earlier finding is fixed: as a sized Card's only child, the windowed scroll region now reaches the Card's bottom edge and takes its corner, and the new Chromium spec covers it.

Non-blocking: a parent with no height mounts every row without a development message; the runtime context still carries the first-frame seed as viewportHeight; and one comment in Table.tsx could be split into shorter sentences.

[Automated review]

Comment on lines +134 to +137
// A windowed table scrolls inside the height its parent gives it. As its
// container's first or last child, the region bleeds over that block edge's
// padding (containerBleed), so its height adds that padding back and it
// ends at the same edge.

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 (INV29): the second sentence runs to about 30 words and joins two topics, the bleed and the height add-back. Suggested:

// A windowed table fills the height its parent gives it. As a first or last
// child, the region bleeds over that edge's padding (containerBleed). Its
// height adds that padding back, so it ends at the edge.

@cixzhang cixzhang added the ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) label Nov 10, 2026
@cixzhang
cixzhang marked this pull request as draft November 10, 2026 05:05
cixzhang and others added 5 commits November 9, 2026 21:05
…optional initialViewportHeight

Renamed before the hook's first stable release, per the virtualizer
vocabulary decision. initialViewportHeight sizes the first frame, on the
server and before the viewport is measured, and bounds the viewport; after
mount the measured viewport sets the window, as it already did. Without it,
the Table's scroll wrapper fills its block-sized parent and the first frame
seeds one row plus overscan. A non-positive or non-finite value falls back
to full rendering. rowHeight is unchanged.

The module record, docs, CLI example, story, api-report and Changesets
follow. New tests seed from the initial height, window without it (server
and client agree on one row plus overscan, and the viewport fills its
parent), and fall back for a zero height; they fail on main.

Co-authored-by: Humberto Virtudes <[email protected]>
…able takes its height from its parent

Per the owner's ruling that the height has one way to be set:
initialViewportHeight sizes no element. It only seeds the first window, on
the server and before the viewport is measured. A windowed Table's scroll
area fills its block-sized parent, so the parent's height bounds it. A
scroll area as tall as its content, holding more rows than the first
window, has no height limit: every row renders and one development warning
says how to size the parent.

The story and the CLI example put the Table in a 320px-tall stack. The
docs, the module record and the Changeset describe the sized-parent
pattern. Tests: the prop sizes nothing, a bounded parent windows with no
warning, and an unbounded parent renders every row with one warning; the
last two fail on the previous head.

Co-authored-by: Humberto Virtudes <[email protected]>
component:Table FR19 now says the windowed viewport's block size is the
height its parent gives it, and that a parent giving none leaves every row
rendered with one development diagnostic. The height-limit reading starts
at false, so a bounded first reading sets no state. isScrollAreaUnbounded
moves above getGeometryViolation's doc block. The hook docs say the Table
fills the parent's whole height: make it the parent's only child, or a flex
child with min-height: 0 beside a heading or toolbar.
…the rename and the Table's height

Per the owner: initialViewportHeight is a required number, as viewportHeight
was, and the change is only the rename plus the Table no longer sizing its
scroll area from it. The optional handling, its one-row seed fallback, the
unbounded-parent detector and its development warning are removed. The
windowed scroll area takes height: 100% and min-height: 0 from its parent.

One test pins the parent-height behavior: with a sized parent the Table
windows; with a parent that gives no height, the scroll area is as tall as
its content and every row renders. FR19 says the block size is the height
the parent gives; the module record says initialViewportHeight seeds only
the first window.
…m edge; docs name the parent height

As its container's first or last child, the windowed scroll region bleeds
over that block edge's padding. Its height: 100% resolved against the
container's content box, so in a 400px Card it ended 24px above the Card's
bottom while it took the bottom corner. The height now adds the bled
padding back on the edges where the bleed applies, so the region ends at
the edge whose corner it takes.

A story puts the windowed Table in a 400px Card, and a Chromium proof
checks that the region's inset from the Card is the same at the top and the
bottom and that it still windows.

The hook docs, the Table docs and the CLI example say: give the Table's
parent a height, fixed or relative, or a flex child, so windowing can bound
the rows; with no height every row renders.
The module record states the principle once: the hook reads the measured
height of the Table's scroll area and never defines it.

Co-authored-by: Humberto Virtudes <[email protected]>
@cixzhang
cixzhang marked this pull request as ready for review November 10, 2026 05:05
@cixzhang
cixzhang force-pushed the feat/table-initial-viewport-height branch from 8e024ad to 77113f0 Compare November 10, 2026 05:06
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 77113f0

@cixzhang
cixzhang marked this pull request as draft November 10, 2026 05:22
@cixzhang
cixzhang marked this pull request as ready for review November 10, 2026 05:22

@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's unit, interaction and accessibility browser jobs are still running on this head, so this is not yet ready to merge.

An engineering owner approved the rewritten module:Table/useTableRowsVirtualization record and component:Table FR19 at this head. The rename and the parent-height rule match them, and in a sized Card the windowed scroll region reaches both block edges and takes the Card's corners.

Non-blocking:

  • A parent with no height mounts every row with no development message (2,000 rows in a 112,038px region in Chromium), so a missed parent height goes unnoticed until the table is large.
  • The runtime context still carries the first-frame seed as viewportHeight, which Table.tsx only tests for != null; a boolean name would stop it reading as a size.
  • The comment at Table.tsx:134-137 could be split into shorter sentences.

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

Changes requested: one fix is needed before this can be approved.

  • Found by CI: packages/core/src/theme/derivedVarRegistry.test.ts:473 fails at this head because Table.tsx adds the private custom properties --_table-bleed-block-start and --_table-bleed-block-end without registering them, so list them in that test's PRIVATE_SYSTEM_VARS with the record that requires them (as the List corner variables are), or write the first- and last-child height without new custom properties.

An engineering owner approved the rewritten module:Table/useTableRowsVirtualization record and component:Table FR19 at this head, and the rename and the parent-height rule match them; in a sized Card the scroll region now reaches both block edges and takes the Card's corners.

Non-blocking: a parent with no height mounts every row with no development message; the runtime context still carries the first-frame seed as viewportHeight; and the comment at Table.tsx:134-137 could be split into shorter sentences.

[Automated review]

Comment thread packages/core/src/Table/Table.tsx Resolved
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 5e07e04

@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's heavy test suites are deferred on this head and run in the pre-merge re-run.

An engineering owner approved the rewritten module:Table/useTableRowsVirtualization record and component:Table FR19 at this head, and the two private bleed variables are now registered, so the theming-surface test that failed before passes. In Chromium the windowed region fills a 400px Card and ends at its edge, and it shrinks to the space left under a toolbar in a flex column.

Non-blocking suggestions:

  • A Table under a parent with no height mounts every row with no development message; the docs say so, but nothing tells a caller at runtime.
  • The runtime context still names the first-frame seed viewportHeight (BaseTable.tsx:1064), the same word the module uses for the measured height; a boolean such as hasBlockViewport would say what the wrapper uses.
  • The comment at Table.tsx:134-137 has a 30-word sentence that joins the bleed and the height add-back; split it.

[Automated review]

@cixzhang
cixzhang marked this pull request as draft November 10, 2026 06:05
@cixzhang
cixzhang marked this pull request as ready for review November 10, 2026 06:05
@cixzhang
cixzhang merged commit 52356e6 into main Nov 10, 2026
129 of 133 checks passed
cixzhang added a commit that referenced this pull request Nov 10, 2026
Main renamed the hook's viewportHeight to initialViewportHeight (#10894).
The Table adapter keeps the shared engine and maps the first-frame height
into the engine's pitch; the module record keeps main's Geometry row and
this branch's list-windowing owners.
cixzhang added a commit that referenced this pull request Nov 10, 2026
(A) merged main, which renamed the hook's viewportHeight to
initialViewportHeight (#10894). Admission and the windowed runtime in the
plugin read the new name; BaseTable keeps this branch's Window boundary.
@humbertovirtudes

Copy link
Copy Markdown
Contributor

Post-merge notes from the virtualization side, thanks for taking this! (it merged before I got to approve)

Two follow-ups Id like, happy to take both:

  1. Unbounded parent mounts every row silently. With no parent height the region is content-tall, so after the seed frame the controller plans all N rows. At 100k thats the cliff windowing exists to prevent, and it slips past the release budgets because every fixture is sized. The runtime already reads clientHeight/scrollHeight, so a one-time dev warning when a windowed Table's viewport holds every row costs no extra layout read. Same trap for a block parent that only sets max-height.
  2. Fallback drops the box. blockViewport is keyed on windowPlan.isWindowed, so a mid-life fallback (e.g. 200% text, rows outgrow rowHeight) switches the region to axis inline, drops height: 100%, resets scroll and spills the full table out of its Card. Keying it on the capability being present makes fallback cost perf, not layout. Pre-existing, but more visible now that the parent owns the height.

Nits: the runtime context still calls the flag viewportHeight and memoizes on the seed, a boolean (isBlockViewport) reads better. initialViewportHeight stays required while the vocabulary card says optional, fine by me since relaxing it later is additive, just worth a line in the record so they agree.

cixzhang added a commit that referenced this pull request Nov 10, 2026
…irst consumer (#10810)

* refactor(core): one shared list-windowing engine, with Table as its first consumer

Moves utils/listWindow.ts to packages/core/src/virtualization/ and lifts
the generic parts of Table's window controller into it:
useListWindow (geometry subscription, first-visible-key anchoring across
data and pitch changes, the pending-anchor scroll, the one retained focus
island and focus return) and the canvas measurement helpers. Table keeps
its admission, logical-position column widths and mounted-row
diagnostics, and calls the shared hook. The geometry snapshot's
bodyOffset is named startOffset. Lab reaches the module only through
Core's private @astryxdesign/core/internal/virtualization entry. No
behavior or public API change.

Co-authored-by: Humberto Virtudes <[email protected]>

* Merge remote-tracking branch 'origin/main' into refactor/shared-virtualization-engine

* Merge main into refactor/shared-virtualization-engine

Main renamed the hook's viewportHeight to initialViewportHeight (#10894).
The Table adapter keeps the shared engine and maps the first-frame height
into the engine's pitch; the module record keeps main's Geometry row and
this branch's list-windowing owners.

* chore: the shared-identity baseline and the list-windowing record name the shared module

The canvas cache textContext moved with the text measurement into
packages/core/src/virtualization/measure.ts, so the shared-identity baseline
key follows it with its memo-cache reason. architecture:list-windowing now
routes packages/core/src/virtualization/ and its private entry, names them
as the module, and says Table uses it while Selector and Chat render every
item. No source change.

* Merge branch 'main' into refactor/shared-virtualization-engine
@github-actions
github-actions Bot deleted the feat/table-initial-viewport-height branch November 11, 2026 06:05

This branch was successfully deployed

1 active deployment
Preview — 5e07e044 Deployed Nov 10, 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) ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) 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.

2 participants