Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

`useVirtualizer({paddingEnd: 800})` creates overscroll issue with `scrollToIndex(last)`

Aperta
#1,257 0 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
68/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
react, typescript
Ambito
frontend

Direzione di ricerca

Inizia con la riproduzione minima collegata e segui i punti di ingresso useVirtualizer e scrollToIndex, concentrandoti sul comportamento di paddingEnd e last-index. Riproduci il problema con i pulsanti forniti, quindi verifica che lo scorrimento fino all'ultimo indice mantenga l'elemento completamente visibile senza far scorrere il contenitore oltre il necessario.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Describe the bug

The paddingEnd option for the useVirtualizer callback is not correctly taken into account when using rowVirtualizer .scrollToIndex(last). Instead the function call scrolls to the end of the scroll container. For every other index this works as intended.

const rowVirtualizer = useVirtualizer({
  count: 100,
  getScrollElement: () => parentRef.current,
  estimateSize: () => 35,
  overscan: 5,
  paddingEnd: 800
})

// ...

<button onClick={() => {
  rowVirtualizer.scrollToIndex(98)
  }}>
  Scroll to 98 (works)
</button>
<button onClick={() => {
  rowVirtualizer.scrollToIndex(99)
  }}>
  Scroll to 99 (overscrolls)
</button>
Your minimal, reproducible example

https://github.com/Freymaurer/tanstack-virtual-padding-overscroll-bug-example

Steps to reproduce
  1. Clone and npm i -> npm run dev the example (fresh vite-react-ts with tanstack virtual dependency) -> open the link printed to console
  2. Click the buttons i added on top of the view
  • "Back to Start" uses scrollToIndex(0)
  • "Scroll to 98 (works)" scrolls to 98, so not last index
  • "Scroll to 99 (overscrolls)" scrolls to the last index
  1. Click on "Back to Start", then "Scroll to 98 (works)". It scrolls with pretty good alignment. The field is shown on the bottom of the scrollContainer
  2. Click on "Back to Start", then "Scroll to 99 (overscrolls)". It overscrolls, the element is not visible on screen. 🐛 I think this is due the library calling more or less "scrollToEnd" instead of "scrollTo" in this scenario.
Expected behavior

I expected the behavior to be consistent. The element at last index should be fully visible after calling the scroll function, instead of scrolling to the scroll container end

How often does this bug happen?

Every time

Screenshots or Videos

After clicking on "Scroll to 98 (works)"

Image

After clicking on "Scroll to 99 (overscrolls)"

Image
Platform

OS: Windows 11
Browser: Tested on Chrome, Edge, Firefox, Opera

tanstack-virtual version

v3.14.9

TypeScript version

v6.0.3

Additional context

No response

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.
Lingua principale
TypeScript
Stelle
7.1k
Fork
466
Merge medio
2g 31m
PR unite (30g)
13

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di TanStack/virtual

Tutte le issue di TanStack/virtual

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.