docs(examples): use spacer rows instead of translateY in the table examples #1338
main fromrefs/pull/1338/head·merged by piecyk 🎯 Changes#
Fixes #585.
The React, Vue, Svelte and Angular table examples moved each row with translateY(start - index * size) inside a div sized to getTotalSize(). The <table> was only as tall as the rendered rows (roughly 560 to 2,200px, against 1,700,000px of rows), so most rows were drawn outside it. That's why a sticky header scrolls away and row borders disappear, as described in the issue.
Following the approach suggested in the issue thread and in #476, the examples now render a spacer row above and below the visible rows:
- Top spacer:
virtualRows[0].start. Bottom spacer:getTotalSize() - lastRow.end. Each spacer is a single<td colSpan>. - The wrapper
divand the transforms are removed, so the table is exactly as tall as all of its rows. theadisposition: sticky; top: 0with a background.border-collapse: collapseon the table. With the default 2px border spacing each row took 36px while the virtualizer assumed 34px.overflow-anchor: noneon the scroll container, so scroll anchoring doesn't adjustscrollTopwhen the spacer heights change.- Vue: rows now get
height: virtualRow.sizelike the other examples. Before, they rendered at their natural height (around 20px), which left blank space at the bottom of the viewport. - Svelte: this example has no global
box-sizing: border-box, so the spacer cells setpadding: 0to keep their height exact. - The intro paragraph in each example described the old translateY trick, so I rewrote it.
The Marko table example already sizes its table to the total size, so I didn't change it. There are no Solid or Lit table examples. Most of the diff is re-indentation from removing the wrapper div (git diff -w is 169+/56-).
Testing: I ran each example in both the dev server and the production build. I checked each one with a headless Playwright script in Chromium, Firefox and WebKit at scroll offsets 0, 3,400, 100,017, 850,000, 1,234,567 and the max. At each offset the script checked that:
- the table height equals the header plus 50,000 x 34px
- the header is pinned to the top of the scroll container
- the row under the header matches the offset
- every rendered row is at
(id - 1) * 34pxfrom the top of thetbody - row 50,000 is the last visible row at the max offset
It also wheel-scrolled (scrollTop only increased and the header stayed pinned), sorted by ID, and jumped to the end. All four examples passed in all three browsers. On main the same script fails on table height and the sticky header.
✅ Checklist#
- I have followed the steps in the Contributing guide.
- I have tested this code locally with
pnpm run test:pr. (test:sherif,test:docsand thebuildtargets for the four examples pass.test:knipfails for me on an unmodifiedmaincheckout too, flaggingscripts/verify-*.tsandmarkdown-link-extractor, so it's unrelated to this change.)
🚀 Release Impact#
- This change affects published code, and I have generated a changeset.
- This change is docs/CI/dev-only (no release).
Happy to take suggested changes, for example putting the sticky styles on th instead of thead, or splitting the non-React examples into a separate PR.
Summary by CodeRabbit#
- Examples
- Updated the Angular, React, Svelte, and Vue table examples to render virtualized rows with spacer rows above and below the visible content.
- Kept table headers visible while scrolling in the React, Svelte, and Vue examples.
- Updated the instructional text to explain the spacer-row approach.
- 1
No actionable comments were generated in the recent review.
Recent review info-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: defaults
- Review profile: CHILL
- Plan: Advanced
- Run ID:
aa36763e-94c9-4100-913d-25dbdc7b53fb
Commits-
Reviewing files that changed from the base of the PR and between c462c6141ea434fdbc52b5dd866bb8db7e4fd07e and 990cd38a359fc9fc2a2617a90d4ccd0e1093bf16.
Files selected for processing: 6-
examples/angular/table/src/app/app.component.tsexamples/react/table/src/index.cssexamples/react/table/src/main.tsxexamples/svelte/table/src/App.svelteexamples/vue/table/src/App.vueexamples/vue/table/src/style.css
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
-
Walkthrough
-
The Angular, React, Svelte, and Vue table examples now render visible virtual rows between top and bottom spacer rows. The examples remove translated row positioning and add styles for sticky headers, collapsed borders, and disabled scroll anchoring.
Changes: Virtual table examples
Priority:Layer / File(s) Summary Spacer-row rendering
examples/angular/table/src/app/app.component.ts,examples/react/table/src/main.tsx,examples/react/table/src/index.css,examples/svelte/table/src/App.svelte,examples/vue/table/src/App.vue,examples/vue/table/src/style.cssThe examples calculate spacer heights from virtual row positions and render the visible rows between spacer rows. They remove the fixed-height wrapper and translated row positioning. Table styles add sticky headers, collapsed borders, and disabled scroll anchoring. Explanatory text describes the spacer-row approach. LowEstimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix · Severity of issue fixed: Low
Suggested reviewers:
kouts,garrettld,marcusvirg
Merge Risk:
Minimal · up to990cd-
No concrete merge-blocking issue remains in the updated table examples.
Pre-merge checks:
4 · 1-
Failed checks: 1 warningCheck name Status Explanation Resolution Docstring Coverage Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. (4 skipped: 4 … Write docstrings for the functions missing them to satisfy the coverage threshold. Passed checks: 4 passed-
Check name Status Explanation Title check The title clearly and concisely identifies the main change: replacing translateY positioning with spacer rows in the table examples. Description check The description includes the required Changes, Checklist, and Release Impact sections. It explains the motivation, implementation details, testing results, and why pnpm run test:pr was not run. The un… Linked Issues check The active directly linked issue is #585. The React example now renders top and bottom spacer rows from the virtual range, removes translated rows and the fixed-height wrapper, and keeps the table siz…Out of Scope Changes check The changes to Vue, Svelte, and Angular apply the same table-sizing fix to equivalent virtual table examples. Their spacer rows, sticky headers, border handling, and scroll-anchor handling are directl… Full details: Description check
-
Explanation
The description includes the required Changes, Checklist, and Release Impact sections. It explains the motivation, implementation details, testing results, and why pnpm run test:pr was not run. The unchecked test requirement is documented with related checks and an unrelated failure on main.
Full details: Linked Issues check
-
Explanation
The active directly linked issue is
#585. The React example now renders top and bottom spacer rows from the virtual range, removes translated rows and the fixed-height wrapper, and keeps the table sized to the virtualized content. The React CSS adds a sticky header with a background, collapsed borders, and disabled scroll anchoring. These changes address the sticky-header and row-border requirements in#585. The PR summary also reports automated browser checks at multiple scroll positions, including the end of the table.
Full details: Out of Scope Changes check
-
Explanation
The changes to Vue, Svelte, and Angular apply the same table-sizing fix to equivalent virtual table examples. Their spacer rows, sticky headers, border handling, and scroll-anchor handling are directly connected to the
#585defect pattern. The updated explanatory text supports the changed implementation. No unrelated published code or unrelated feature changes are shown, and the Marko example remains unchanged.
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. (4 skipped: 4 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment `@coderabbitai help` to get the list of available commands.-
piecyk approved these changes
Thanks @dgesteves, nice cleanup!
View your CI Pipeline Execution ↗ for commit 990cd38a359fc9fc2a2617a90d4ccd0e1093bf16
Command Status Duration Result nx affected --targets=test:sherif,test:knip,tes...✅ Succeeded 35s View ↗ nx run-many --target=build --exclude=examples/**✅ Succeeded 16s View ↗
☁️ Nx Cloud last updated this comment at
2026-10-26 11:35:29UTCMore templates
- tanstack-marko-virtual-example-chat
- tanstack-marko-virtual-example-chat-pretext
- tanstack-marko-virtual-example-dynamic
- tanstack-marko-virtual-example-fixed
- tanstack-marko-virtual-example-grid
- tanstack-marko-virtual-example-infinite-scroll
- tanstack-marko-virtual-example-padding
- tanstack-marko-virtual-example-pretext
- tanstack-marko-virtual-example-scroll-padding
- tanstack-marko-virtual-example-smooth-scroll
- tanstack-marko-virtual-example-ssr
- tanstack-marko-virtual-example-ssr-fetch
- tanstack-marko-virtual-example-ssr-restore
- tanstack-marko-virtual-example-ssr-slice
- tanstack-marko-virtual-example-sticky
- tanstack-marko-virtual-example-table
- tanstack-marko-virtual-example-variable
- tanstack-marko-virtual-example-window
- tanstack-marko-virtual-example-window-ssr-slice
- tanstack-react-virtual-example-chat
- tanstack-react-virtual-example-dynamic
- tanstack-react-virtual-example-fixed
- tanstack-react-virtual-example-infinite-scroll
- tanstack-react-virtual-example-padding
- tanstack-react-virtual-example-pretext
- tanstack-react-virtual-example-scroll-padding
- tanstack-react-virtual-example-smooth-scroll
- tanstack-react-virtual-example-sticky
- tanstack-react-virtual-example-table
- tanstack-react-virtual-example-variable
- tanstack-react-virtual-example-window
- tanstack-svelte-virtual-example-dynamic
- tanstack-svelte-virtual-example-fixed
- tanstack-svelte-virtual-example-infinite-scroll
- tanstack-svelte-virtual-example-smooth-scroll
- tanstack-svelte-virtual-example-sticky
- tanstack-svelte-virtual-example-table
- tanstack-vue-virtual-example-dynamic
- tanstack-vue-virtual-example-fixed
- tanstack-vue-virtual-example-infinite-scroll
- tanstack-vue-virtual-example-padding
- tanstack-vue-virtual-example-scroll-padding
- tanstack-vue-virtual-example-smooth-scroll
- tanstack-vue-virtual-example-sticky
- tanstack-vue-virtual-example-table
- tanstack-vue-virtual-example-variable
- @tanstack/virtual-example-angular-chat
- @tanstack/virtual-example-angular-dynamic
- @tanstack/virtual-example-angular-fixed
- @tanstack/virtual-example-angular-infinite-scroll
- @tanstack/virtual-example-angular-padding
- @tanstack/virtual-example-angular-smooth-scroll
- @tanstack/virtual-example-angular-sticky
- @tanstack/virtual-example-angular-table
- @tanstack/virtual-example-angular-variable
- @tanstack/virtual-example-angular-window
- tanstack-lit-virtual-example-dynamic
- tanstack-lit-virtual-example-fixed
@tanstack/angular-virtual
npm i https://pkg.pr.new/@tanstack/angular-virtual@1338@tanstack/lit-virtual
npm i https://pkg.pr.new/@tanstack/lit-virtual@1338@tanstack/marko-virtual
npm i https://pkg.pr.new/@tanstack/marko-virtual@1338@tanstack/react-virtual
npm i https://pkg.pr.new/@tanstack/react-virtual@1338@tanstack/solid-virtual
npm i https://pkg.pr.new/@tanstack/solid-virtual@1338@tanstack/svelte-virtual
npm i https://pkg.pr.new/@tanstack/svelte-virtual@1338@tanstack/virtual-core
npm i https://pkg.pr.new/@tanstack/virtual-core@1338@tanstack/vue-virtual
npm i https://pkg.pr.new/@tanstack/vue-virtual@1338commit:
990cd38piecyk merged this88b9773
piecyk closed this
Sign in to join this conversation.
⚠️ No Changeset found#
Latest commit: 990cd38a359fc9fc2a2617a90d4ccd0e1093bf16
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
This PR includes no changesets
When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR