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 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
领域
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 摘要。