Skip to content

Commit

Permalink
fix: catch rare error with scrolling when list gets voided
Browse files Browse the repository at this point in the history
  • Loading branch information
johann-crabnebula committed Feb 7, 2024
1 parent 6fd60b8 commit 91d2bdd
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions clients/web/src/components/auto-scroll-pane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,15 @@ export function AutoScrollPane<AutoScrollItem>(
);

createEffect(() => {
if (props.shouldAutoScroll() && props.dataStream.length > 0)
virtualizer().scrollToIndex(props.dataStream.length - 1);
if (props.shouldAutoScroll() && props.dataStream.length > 0) {
// When updating the filter really quick (fast typing for example) it is possible to void the virtual items
// before the scroll can be performed, which will lead to an error
try {
virtualizer().scrollToIndex(props.dataStream.length - 1);
} catch (e) {
/* intentionally ignore */
}
}
});

return (
Expand Down

0 comments on commit 91d2bdd

Please sign in to comment.