T
TanStack3y ago
stormy-gold

Svelte-virtual: mousewheel and keydown cause nonstop scrolling

Hi, I'm trying to leverage svelte-virtual by following the React examples and porting to svelte. If I scroll my container using the mouse to grab a specific scroll position, it works fine. But if I use my mousewheel or keyboard arrow keys to scroll more than a few rows rapidly, suddenly I get in a loop where the component keeps scrolling on its own. Has anyone seen this before and know how to address?
2 Replies
stormy-gold
stormy-goldOP3y ago
Here is a CodeMirror reproduction of the issue. I have a div based virtual list, and a table based virtual list. The div one works fine. When I try to use the table pattern that I've seen demonstrated in React examples, the table scrolling goes haywire when using scrollwheel or keyboard. Any ideas? https://codesandbox.io/s/svelte-table-virtual-list-bug-dv8xk7
skokenes
CodeSandbox
Svelte Table Virtual List bug - CodeSandbox
Svelte Table Virtual List bug by skokenes using @tanstack/svelte-virtual, svelte
stormy-gold
stormy-goldOP3y ago
Solved, needed to add a key to the each template in Svelte, like:
{#each virtualRows as virtualRow (virtualRow.index)}
{#each virtualRows as virtualRow (virtualRow.index)}

Did you find this page helpful?