Skip to content
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

Failed to work with TanStack/virtual #499

Closed
B-l-u-e-b-e-r-r-y opened this issue Feb 10, 2023 · 6 comments
Closed

Failed to work with TanStack/virtual #499

B-l-u-e-b-e-r-r-y opened this issue Feb 10, 2023 · 6 comments
Labels
🍌 question react Issue has a connection to the React framework. 💦 Virtualization Issue has a connection with a scroll virtualization library.

Comments

@B-l-u-e-b-e-r-r-y
Copy link

Hello everyone!
I'm using the library TanStack/virtual, but it seems to conflict with OverlayScrollbars needing to set a height for the scrollbar to appear.

Here is an example: CodeSandbox

<div ref={osRef} style={{ height: "95vh" }}>
If the height is specified, the scrollbar appears.

<div ref={osRef}>
Without specifying height, the virtualizer works, but the scrollbar doesn't appear.

Could I show the scrollbar without setting the height?
Or have any ideas?
Thanks for your help.

@KingSora
Copy link
Owner

KingSora commented Feb 10, 2023

@B-l-u-e-b-e-r-r-y Good day :)

Since you are using the useWindowVirtualizer hook you have to also initialize OverlayScrollbars to the window (body) element. I've created a demo for your here: https://codesandbox.io/s/youthful-shockley-0c17lm?file=/src/App.js

In case you wanna use the useVirtualizer hook I've also made a demo for you: https://codesandbox.io/s/bold-robinson-78t7nz?file=/src/App.js

@KingSora KingSora added 🍌 question react Issue has a connection to the React framework. labels Feb 10, 2023
@B-l-u-e-b-e-r-r-y
Copy link
Author

@KingSora
Wow! You’re a lifesaver!

@andreamazzatxt
Copy link

Hi, I tried to implement the second example using useVirtualizer hook, scrollbar works fine but the rows are not virtualized. If you check @KingSora demo there are 300 rows in the dom.
Removing the external wrapper ( the overlayscrollbars one ) useVirtualizer works fine.

@Victor-Varghese
Copy link

Victor-Varghese commented Jul 19, 2023

Hi @KingSora useVirtualizer code doesn't work properly. Rows are not virtualised. Can you help?

I tried using the normal scrollbar component. Same thing, rows will not load

@KingSora
Copy link
Owner

KingSora commented Jul 19, 2023

@andreamazzatxt @Victor-Varghese Sorry for the late reply - In the example I forgot to limit the size of the viewport div.. so the virtualizer measured the div which could expand endlessly thus is could load all of the items into it. Setting a maxHeight: '100%' (or any other fixed maxHeight) on that div fixed the issue: https://codesandbox.io/s/bold-robinson-78t7nz?file=/src/App.js

I replaced that example in my earlier post.

@KingSora KingSora added the 💦 Virtualization Issue has a connection with a scroll virtualization library. label Oct 19, 2023
@KingSora
Copy link
Owner

Related: #639

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍌 question react Issue has a connection to the React framework. 💦 Virtualization Issue has a connection with a scroll virtualization library.
Projects
None yet
Development

No branches or pull requests

4 participants