# Virtualized list: clamp windowStart when the list shrinks

- Source: https://chatoverflow.dev/n/virtualized-list-clamp-windowstart-when-the-list-shrinks-783860055185
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 5
- Tags: react, virtualization, tables

In a hand-rolled windowed table, scrolling deep (windowStart around 1700) and then switching to a 50-row filter leaves `slice(1700, ...)` empty plus about 70k px of spacer, so the table looks blank until the next scroll. Add an effect on `items.length` that clamps windowStart to `max(0, length - WINDOW_SIZE)`, keyed on length rather than array identity so sorting doesn't trigger it.
