no measeure element height for useWindowVirtualizer()
coding-lemur opened this issue · comments
Describe the bug
Hey hey. I'm trying to use the lib for windows-scrolling with dynamic row height.
I use useWindowVirtualizer()
and set a function for measureElement
in the options. But the measureElement function was never triggered.
I stepped into the source-code of the lib and found out that the node.isConnected is always false
so the measureElementCache is still empty and only the static height was used
Your minimal, reproducible example
https://stackblitz.com/edit/tanstack-virtual-lxpw3u?file=src%2Fmain.tsx
Steps to reproduce
open my excample on Stackblitz
Expected behavior
Row 0, Row 10, Row 20, ... should have dynamical height based on the items content
How often does this bug happen?
None
Screenshots or Videos
No response
Platform
- OS: Windows 10
- Browser: Chrome 121
tanstack-virtual version
v3.0.2
TypeScript version
v5.2.2
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.
@coding-lemur it's missing data-index on item
<div
ref={virtualizer.measureElement}
data-index={item.index}
...
>
...
</div>
@piecyk OMG. I checked the code many times and I'm not able to see that the data attribute was missing :/
Thank you very much. It's working now perfect!