ScrollableList: track the second item instead of the top one

This commit is contained in:
Alex Gleason 2022-06-02 21:22:40 -05:00
parent 606d6297a8
commit 526d8a1d83
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7

View file

@ -170,7 +170,9 @@ const ScrollableList = React.forwardRef<VirtuosoHandle, IScrollableList>(({
};
const handleRangeChange = (range: ListRange) => {
topIndex.current = range.startIndex;
// HACK: using the first index can be buggy.
// Track the second item instead, unless the endIndex comes before it (eg one 1 item in view).
topIndex.current = Math.min(range.startIndex + 1, range.endIndex);
handleScroll();
};