svelte-virtual renders no rows when the scroll element is bound after the store subscribes
維護者通常 1 天內回覆
評估
- 難度
- 4/5
- 預估耗時
- 1-2 天
- 新手友好度
- 35/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 停滯
- 技術堆疊
- typescript
- 領域
- frontend
研究方向
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.
由索引模型根據 Issue 內容生成。
描述
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.
- 主要語言
- TypeScript
- 星號
- 7.2k
- 分支
- 490
- 平均合併
- 15 小時 28 分鐘
- 30 天內合併 PR
- 48
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
TanStack/virtual 的其他 Issue
-
anchorTo: 'end' does not keep the reading position when only paddingStart changes可能已有人在做 @duongynhi000001-crypto 於 3 天前認領。 未關閉
難度 3/5 1-2 天 新手友好度 30/100
維護者通常 1 天內回覆
-
anchorTo: 'end' loses the end when the scroll element shrinks可能已有人在做 @langleyd 於 32 天前認領。 未關閉
難度 3/5 1-2 天 新手友好度 68/100
維護者通常 1 天內回覆
-
marko-virtual: scrollToEnd during an in-flight prepend strands the view one prepend above the bottom (chat-pretext e2e fails on CI)可能已有人在做 @officialasishkumar 於 6 天前認領。 未關閉
難度 4/5 3-5 天 新手友好度 55/100
維護者通常 1 天內回覆
-
Scroll correction sometimes gets stuck on estimating row sizes可能已有人在做 @itisrmk 於 1 天前認領。 未關閉
難度 4/5 3-5 天 新手友好度 42/100
TanStack/virtual#1252 · 2 則留言 ·
維護者通常 1 天內回覆
-
eslint-plugin-react-hooks v7 warning for useVirtualizer: Compilation Skipped: Use of incompatible library可能已有人在做 關聯的 PR 仍在進行中或已合併。 未關閉
難度 4/5 3-5 天 新手友好度 45/100
TanStack/virtual#1119 · 11 則留言 · 32 個 reaction ·
維護者通常 1 天內回覆
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 70/100
backnotprop/plannotator#2914 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
microsoft/vscode-containers#655 ·
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 77/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 72/100
dsh-tauri-desk/deepseek-harness-desktop#1477 · 1 則留言 ·