Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

Svelte onChange stops firing after a partial setOptions update

已關閉 適合新手
#1,343 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

@clean99 已經在處理了。

開始於 2026年10月28日。

  • #1344 來自 @clean99 —— 未關閉

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
68/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
javascript, typescript
領域
frontend

研究方向

從 packages/svelte-virtual/src/ 下的 Svelte 適配器原始碼開始,createVirtualizer 和 createWindowVirtualizer 會在此合併選項並重新建立 store 訂閱。執行連結的再現(在 StackBlitz/repo 中執行 npm install && npm start),觀察 onChange 計數器在 setOptions({ count: 110 }) 之後停止,然後檢查部分更新在重建 store 時是否會丟棄現有的 onChange。完成意味著兩個建構函式在部分更新後再次觸發 onChange,並由再現與該套件的測試驗證。

由索引模型根據 Issue 內容生成。

描述

Describe the bug

After calling setOptions({ count: 110 }), an existing onChange callback stops firing. The store still updates. This affects both createVirtualizer and createWindowVirtualizer.

Your minimal, reproducible example

https://github.com/clean99/virtual-svelte-onchange-repro (StackBlitz: https://stackblitz.com/github/clean99/virtual-svelte-onchange-repro)

Its reproduce.mjs needs only @tanstack/[email protected] and [email protected]. Run npm install and npm start. It uses the public measure() method to trigger a state-change notification, without rendering a component or relying on browser timing.

Steps to reproduce
  1. Create a Svelte virtualizer with count: 100, estimateSize: () => 40, getScrollElement: () => null, and an onChange counter. Subscribe to its store.
  2. Call measure(): the counter becomes 1.
  3. Call setOptions({ count: 110 }), then measure() again.
  4. The counter stays at 1 instead of becoming 2. The reproduction asserts this for both exported constructors.
Expected behavior

An omitted option should remain unchanged in a partial update. The existing onChange callback should still fire when virtualizer state changes, as described in the API reference.

How often does this bug happen?

Every time.

Screenshots or Videos

Not applicable; the reproduction checks callback invocations directly.

Platform

macOS 26.5.2, Node.js 24.16.0. No browser is needed for this reproduction.

tanstack-virtual version

@tanstack/svelte-virtual 3.13.49, Svelte 4.2.20.

TypeScript version

The reproduction is JavaScript. The regression tests use TypeScript 5.9.3.

Additional context

The Svelte infinite-scroll example uses a count-only update after fetching another page. Adding an onChange callback to that pattern loses the callback after the update.

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
分支
479
平均合併
21 小時 1 分鐘
30 天內合併 PR
41

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

TanStack/virtual 的其他 Issue

查看 TanStack/virtual 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。