[BUG] scroll up glitch when setting `initialTopMostItemIndex` in Some Mobile Browsers and Webviews
See original GitHub issueDescribe 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):
- Go to Reproduction
- I recommend installign the Expo Go app from the app store and scanning the QR code to load the reproduction on your iOS device.
- scroll down to some index in the list
- click “Toggle List Visibility” to hide the list
- Click again to show it and be restored toy our original position
- Scroll up
- Observe the glitchiness of the scroll
Steps to reproduce the behavior (iOS Chrome Browser):
- Go to Sandbox
- scroll down to some index in the list
- click “Toggle List Visibility” to hide the list
- Click again to show it and be restored toy our original position
- Scroll up
- Observe the glitchiness of the scroll
Expected behavior It should work as it does in chrome desktop etc
Issue Analytics
- State:
- Created 10 months ago
- Comments:8 (7 by maintainers)

Top Related StackOverflow Question
Thanks for the reply – I’ve tested it and indeed, in 2.9.2 does not have this issue
🎉 This issue has been resolved in version 3.1.4 🎉
The release is available on:
Your semantic-release bot 📦🚀