Describe the bug
I don't know if this is a bug that can be fixed on your side but I experienced a strange behavior when rendering my virtualized list inside a portal. This occurs when I create an anchor for the portal inside useEffect and use the node created with document.createElement. If I use document.body or something reachable with document.getElementById instead, it works.
Context: I am using a ComboBox and render the list inside a dropdown or inside a modal on mobile devices. I did not notice it at first because in my development workflow the items usually get fetched after initially rendering the list. These items get cached based on the query so they don't have to fetched again. You can simulate this behavior by changing the default value in the example.
PS: Thanks for creating and maintaining this library!
Your minimal, reproducible example
https://codesandbox.io/p/sandbox/vigilant-kirch-v8q98r
Steps to reproduce
- Press "Open modal"
=> First items are squished
- Change
createPortal container to document.body
- Reload and press "Open modal"
=> First items are not squished
Lazy: Change default state in the options from _options to null
- Press "Open modal"
=> First items are not squished
Expected behavior
Items are not squished
How often does this bug happen?
Every time
Screenshots or Videos

Platform
OS: Windows 11
Browser: Google Chrome 117.0.5938.132 64-Bit
React: 17.0.2 and 18.2.0
tanstack-virtual version
3.0.0-beta.61
TypeScript version
No response
Additional context
No response
Terms & Code of Conduct
Describe the bug
I don't know if this is a bug that can be fixed on your side but I experienced a strange behavior when rendering my virtualized list inside a portal. This occurs when I create an anchor for the portal inside
useEffectand use the node created withdocument.createElement. If I usedocument.bodyor something reachable withdocument.getElementByIdinstead, it works.Context: I am using a ComboBox and render the list inside a dropdown or inside a modal on mobile devices. I did not notice it at first because in my development workflow the items usually get fetched after initially rendering the list. These items get cached based on the query so they don't have to fetched again. You can simulate this behavior by changing the default value in the example.
PS: Thanks for creating and maintaining this library!
Your minimal, reproducible example
https://codesandbox.io/p/sandbox/vigilant-kirch-v8q98r
Steps to reproduce
=> First items are squished
createPortalcontainer todocument.body=> First items are not squished
Lazy: Change default state in the options from
_optionstonull=> First items are not squished
Expected behavior
Items are not squished
How often does this bug happen?
Every time
Screenshots or Videos
Platform
OS: Windows 11
Browser: Google Chrome 117.0.5938.132 64-Bit
React: 17.0.2 and 18.2.0
tanstack-virtual version
3.0.0-beta.61
TypeScript version
No response
Additional context
No response
Terms & Code of Conduct