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
{{ message }}
Repository navigation
react-virtual – Visible items are incorrect on first render when using max-height on container #871
See that the virtualizer is showing only 2 items, when more can fit
Wait 3s, then observe when re-render is forced that virtualizer now shows the correct number of items
Expected behavior
When the virtualizer is used with dynamically sized elements and a container with max-height instead of a fixed height, after measure some elements it should show the correct number of visible items needed to fill the container space.
How often does this bug happen?
Every time
Screenshots or Videos
CleanShot.2024-11-01.at.09.10.29.mp4
Platform
OSX Chrome
tanstack-virtual version
v3.10.8
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.
I'm facing the same issue. A workaround I found is to add initialRect option to useVirtualizer, and manually set a height estimated by rows.length * rowSize (being rowSize the same value returned by estimateSize function).
With this, the initial render had the appropriate estimated height, and then all the rows properly rendered
Activity
gndelia commentedon Feb 27, 2025
I'm facing the same issue. A workaround I found is to add
initialRectoption touseVirtualizer, and manually set aheightestimated byrows.length * rowSize(beingrowSizethe same value returned byestimateSizefunction).With this, the initial render had the appropriate estimated height, and then all the rows properly rendered
fix(virtual-core): make getState() free of side effects