svelte-virtual renders no rows when the scroll element is bound after the store subscribes
Maintainer antworten meist innerhalb von 1 Tag
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 35/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- typescript
- Bereich
- frontend
Rechercherichtung
Start with the Svelte adapter’s createVirtualizer implementation and compare when it calls _willUpdate with the other adapters’ render or mount hooks. Reproduce the issue using the linked svelte-late-scroll-element example and inspect how a late bind:this assignment is handled. Done means all three lists render their seven visible rows; pull request #1368 is already open against this issue.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Describe the bug
A Svelte virtualizer whose scroll element is assigned with bind:this renders no rows when the store is subscribed before the element is bound and nothing calls setOptions afterwards. The store's start callback reads getScrollElement() once, gets null, and attaches no observers.
This hits createVirtualizer inside $derived on Svelte 5 (the empty table in #866, worked around there by calling $virtualizer._willUpdate() after mount) and a virtualizer created once, as suggested in #656, when the count does not change after mount. The Svelte examples render because $: virtualizer = createVirtualizer(...) re-creates the virtualizer after the element is bound.
Your minimal, reproducible example
https://github.com/clean99/oss-pr-media/tree/main/tanstack-virtual/svelte-late-scroll-element
Steps to reproduce
- In the reproduction directory, run
npm ciandnpm run dev, then open the printed URL. - The page shows three lists of 1000 rows. Each has a 200px scroll container assigned with
bind:this. - "$derived" and "created once" show 0 rows and an empty container. "control" shows 7 rows: its
getScrollElementreads the element inside$derived, so it is re-created after binding.
Expected behavior
All three lists render their visible rows (7 for a 200px container with 35px rows).
How often does this bug happen?
Every time.
Screenshots or Videos
The heading above each list prints its row count.
Platform
macOS, Chromium (Playwright headless shell), Node.js 24.8.0, Svelte 5.57.3. The created-once component also renders 0 rows on Svelte 4.2.20.
tanstack-virtual version
@tanstack/svelte-virtual 3.13.52
TypeScript version
The reproduction uses JavaScript.
Additional context
The other adapters call _willUpdate after render or mount (React's layout effect, the Vue watcher on getScrollElement, Solid's onMount, Angular's afterRenderEffect, Lit's hostUpdated), so they pick up a ref assigned during render. In the Svelte adapter it only runs inside setOptions.
Terms & Code of Conduct
- I agree to follow this project's Code of Conduct
- I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 7.2k
- Forks
- 490
- Ø Merge
- 15 Std. 28 Min.
- Gemergte PRs (30 T.)
- 48
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus TanStack/virtual
-
anchorTo: 'end' does not keep the reading position when only paddingStart changesEvtl. vergeben @duongynhi000001-crypto hat das vor 3 Tagen übernommen. Offen
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 30/100
Maintainer antworten meist innerhalb von 1 Tag
-
anchorTo: 'end' loses the end when the scroll element shrinksEvtl. vergeben @langleyd hat das vor 32 Tagen übernommen. Offen
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 68/100
Maintainer antworten meist innerhalb von 1 Tag
-
marko-virtual: scrollToEnd during an in-flight prepend strands the view one prepend above the bottom (chat-pretext e2e fails on CI)Evtl. vergeben @officialasishkumar hat das vor 6 Tagen übernommen. Offen
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 55/100
Maintainer antworten meist innerhalb von 1 Tag
-
Scroll correction sometimes gets stuck on estimating row sizesEvtl. vergeben @itisrmk hat das vor 1 Tag übernommen. Offen
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 42/100
TanStack/virtual#1252 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
eslint-plugin-react-hooks v7 warning for useVirtualizer: Compilation Skipped: Use of incompatible libraryEvtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. Offen
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 45/100
TanStack/virtual#1119 · 11 Kommentare · 32 Reaktionen ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in TanStack/virtual
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
backnotprop/plannotator#2914 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
microsoft/vscode-containers#655 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 77/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
dsh-tauri-desk/deepseek-harness-desktop#1477 · 1 Kommentar ·