New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(useVirtualList): List sometimes missing elements #2477
Conversation
if (typeof itemSize === 'number') | ||
return Math.ceil(containerHeight / itemSize) | ||
return Math.ceil(containerSize / itemSize) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Height naming was from when list was vertical only. Size is more appropriate, IMO
capacity = i | ||
if (sum > containerSize) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving capacity out of the if is the fix. Without this, if the original list size is smaller than what could fit in the view, we end up with a capacity of 1 + overscan
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't the same thing be done with 'offset = i' in function 'createGetOffset'?
Description
Fixes #2065
This fixes an issue that was closed, seemingly due to inactivity, but was not actually fixed.
This fixes a single scenario I was able to isolate, but I'm not sure if there are actually others. One of the added tests covers the scenario.
Additional context
The scenario I can reliably reproduce the issue in is if the original list is smaller than the capacity of the virtual list. It just doesn't render all the items in that case.
For example, render a list of 5 elements when the screen is able to show 10. With an overscan of 2, 2 + 1 elements will be rendered. With an overscan of 1, it will be 1 + 1 = 2, etc.
Extra notes
It seems that there is still some faulty logic around how overscan works. If you set the overscan to 0, based on tests, you can't really get the first item in the original list to display, possibly the last as well.
I would love to look into that, but it's a bit difficult to unravel what all the start/end variables are intended to be. Not always clear if they are 0 or 1-indexed, inclusive or exclusive, etc.
After this is accepted in, I can look into investigating that and opening a ticket.
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).