Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

Svelte onChange stops firing after a partial setOptions update

Fechada Para iniciantes
#1,343 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

@clean99 já está trabalhando nisso.

Desde 28/10/2026.

  • #1344 de @clean99 — aberto

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
68/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
javascript, typescript
Domínio
frontend

Direção de pesquisa

Comece no código-fonte do adaptador Svelte em packages/svelte-virtual/src/, onde createVirtualizer e createWindowVirtualizer mesclam opções e recriam a assinatura da store. Execute a reprodução vinculada (npm install && npm start no StackBlitz/repo) para observar o contador onChange parar após setOptions({ count: 110 }), depois verifique se a atualização parcial descarta o onChange existente ao reconstruir a store. Concluído significa que ambos os construtores disparam onChange novamente após uma atualização parcial, verificado pela reprodução e pelos testes do pacote.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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.
Linguagem predominante
TypeScript
Estrelas
7.2k
Forks
479
Merge médio
21h 1min
PRs com merge (30d)
41

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de TanStack/virtual

Todas as issues de TanStack/virtual

Issues semelhantes

Mais issues de TypeScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.