question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

useWindowVirtualizer shows blank when having other contents on page

See original GitHub issue

Describe the bug

Hello, thanks for open sourcing this great library.

One potential bug: when using useWindowVirtualizer, I noticed the virtualized content would start showing blank items when scrolling down, if the page has some other normal contents on top.

Your minimal, reproducible example

https://codesandbox.io/s/friendly-noether-6f2p8z?file=/src/App.tsx

Steps to reproduce

scroll down on the sandbox demo

Expected behavior

the virtualized content should not blank on the visible window

How often does this bug happen?

No response

Screenshots or Videos

No response

Platform

MacOS

tanstack-virtual version

v3.0.0-beta.18

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.

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:6
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
piecykcommented, Oct 15, 2022

Yeah, here we need to add something like scrollMargin that will handle this cases. @dylanwulf was on right path, internally we need to skip altering scrollToFn when syncing scroll position.

0reactions
dylanwulfcommented, Sep 29, 2022

I was able to fix the scrolling methods by providing a custom scrollToFn:

scrollToFn: (offset, canSmooth, instance) => {
  window.scrollTo({
    top:
      offset +
      window.scrollY +
      (virtualListRef.current?.getBoundingClientRect().top ?? 0),
    behavior: canSmooth ? "smooth" : undefined
  });

but now my problem is that it automatically scrolls to the first element of my list on mount, even if I don’t have initialOffset specified.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Virtualized - Screen going blank after scrolling a long ...
But I'm facing the below issue. enter image description here. When I try scrolling to the bottom for 2 seconds, it's blank then...
Read more >
Virtualize large lists with react-window - web.dev
Since items in a virtualized list only change when the user scrolls, blank space can briefly flash as newer entries are about to...
Read more >
TanStack virtual Issues - Giters
Scroll stucks when having fixed overlay with pointer-events: none ... useWindowVirtualizer shows blank when having other contents on page.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found