Svelte onChange stops firing after a partial setOptions update
维护者通常 1 天内回复
评估
- 难度
- 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
- Create a Svelte virtualizer with
count: 100,estimateSize: () => 40,getScrollElement: () => null, and anonChangecounter. Subscribe to its store. - Call
measure(): the counter becomes 1. - Call
setOptions({ count: 110 }), thenmeasure()again. - 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
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
TanStack/virtual 的其他 Issue
-
anchorTo: 'end' loses the end when the scroll element shrinks可能已有人在做 @langleyd 于 22 天前认领。 未关闭
难度 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)可能已有人在做 @prayaggaikwad96 于 16 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 55/100
维护者通常 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 天内回复
-
难度 4/5 3-5 天 新手友好度 35/100
TanStack/virtual#1099 · 1 个 reaction ·
维护者通常 1 天内回复
相似的 Issue
-
Parallel reticle_verify opens per-flow leases without the source lease's ignoreHTTPSErrors可能已有人在做 @as992949791 今天认领。 未关闭good first issue help wanted
难度 2/5 1-3 小时 新手友好度 85/100
reticlehq/reticle#2033 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
area:quality p3-medium ready-for-agent type:docs
难度 2/5 1-3 小时 新手友好度 83/100
fderuiter/deruiter.dev#3589 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
manfredsteyer/angular-oauth2-oidc#1514 ·
-
难度 2/5 1-3 小时 新手友好度 76/100
marmelab/react-admin#11431 ·
维护者通常 1 天内回复