You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Inside a useEffect, using Virtualizer.scrollToIndex when the list is empty is throwing the following error:
Uncaught Error: Unexpected undefined at notUndefined at Virtualizer.getOffsetForIndex
Admittedly, it is reasonable to have to add a condition in order to avoid calling scrollToIndex when the list is empty. Due to the nature of side effects + asynchronicity, however, there is an edge case in which scrollToIndex may have been called just as the list became empty, thus causing an error.
Is there any insight into why Virtualizer.scrollToIndex throws an error when called upon an empty list? Would it be better to handle this as a warning instead of an error? Or if the list is empty, have scrollToIndex return early instead of trying to execute?
Unfortunately, wrapping scrollToIndex inside a try/catch block within useEffect does not swallow the error.
Inside useEffect, call scrollToIndex(0) when the list is empty
See that an uncaught error is thrown
Expected behavior
As a user, I expected scrollToIndex to not throw an error when the virtual list is empty.
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
macOS - Chrome v.122.0.6261.129
tanstack-virtual version
v3.2.0
TypeScript version
No response
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.