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.

[BUG] scroll up glitch when setting `initialTopMostItemIndex` in Some Mobile Browsers and Webviews

See original GitHub issue

Describe the bug I have implemented basic scroll restoration in a virtuoso list by setting initialTopMostItemIndex which seems to work well EXCEPT in Mobile Chrome and iOS Safari Webviews.

The behavior is such that scrolling up and down is smooth, unless initialTopMostItemIndex is set. The behavior is such that, let’s say you set the top most item index to 50 – scrolling down works fine, but scrolling up will only let you scroll about an item at a time before the scroll gets interrupted by an unknown bug.

Reproduction I have created a reproduction in codesandbox as well as a snack app which reproduces the behavior.

Here is the sandbox: https://codesandbox.io/s/recursing-ace-j2zvxt?file=/src/App.tsx

I added a button that hides the list so that you can simulate un-mounting the list and mounting it by toggling visibility.

The scroll position at time of unmount is stored in parent component’s state and passed down to restore the scroll.

This issue is reproducible on mobile chrome with just the sandbox.

For the webview reproduction I also created a expo snack with a reproduction here: https://snack.expo.dev/@coincircle/webview-example

I am comfortable with making a PR myself and doing whatever testing/debugging is needed on my end to solve the problem, but I figured I’d bring this up as maybe you might have an idea off the top of your head regarding as to what can be the cause here. It’s quite a strange issue given that webviews are just embedded safari windows, yet this issue is not reproducible in the safari browser, only in a webview (and mobile chrome).

To Reproduce Steps to reproduce the behavior (iOS Webview):

  1. Go to Reproduction
  2. I recommend installign the Expo Go app from the app store and scanning the QR code to load the reproduction on your iOS device.
  3. scroll down to some index in the list
  4. click “Toggle List Visibility” to hide the list
  5. Click again to show it and be restored toy our original position
  6. Scroll up
  7. Observe the glitchiness of the scroll

Steps to reproduce the behavior (iOS Chrome Browser):

  1. Go to Sandbox
  2. scroll down to some index in the list
  3. click “Toggle List Visibility” to hide the list
  4. Click again to show it and be restored toy our original position
  5. Scroll up
  6. Observe the glitchiness of the scroll

Expected behavior It should work as it does in chrome desktop etc

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
coopermaruyamacommented, Nov 15, 2022

Thanks for the reply – I’ve tested it and indeed, in 2.9.2 does not have this issue

0reactions
github-actions[bot]commented, Nov 16, 2022

🎉 This issue has been resolved in version 3.1.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Fix Scrolling Not Working Issue in Chrome (2022)
How to Fix the Scroll Wheel not Working in Chrome Problem. #Chrome #Google #HowTo #Mac #BigSur #Catalina ...
Read more >
Position fixed on chrome mobile causing element to move on ...
If you have an unexpected horizontal scrolling in addition to this issue, then that is probably the root cause of the weird vertical...
Read more >
Mobile view glitches on scroll to the bottom - WordPress.org
On mobile view (Using Android) when I scroll down to the bottom it glitches. But not always the first time it happens, sometimes...
Read more >
Why A Website Won't Scroll & How to Fix it
If you are unable to scroll on your mobile device, there are a few things that could cause that problem. First, try using...
Read more >
overscroll-behavior - CSS: Cascading Style Sheets | MDN
The overscroll-behavior CSS property sets what a browser does when reaching the boundary of a scrolling area.
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