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

[BUG] Scroll position change when prepending one item of unknown height with increaseViewportBy #947

Open
danielsantiago opened this issue Jul 12, 2023 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@danielsantiago
Copy link

Describe the bug
When you are at the top of the list, and you prepend a new item with an unknown height, the list is changing the scroll position.

Reproduction
https://codesandbox.io/s/sandpack-project-forked-gzs242?file=/App.js

To Reproduce
Steps to reproduce the behavior:

  1. Go to the sandbox
  2. Click 'prepend'

Expected behavior
When prepend there should be no automatic scroll changes.

Screenshots
https://github.com/petyosi/react-virtuoso/assets/619122/8dfcfe79-7795-41f4-bdf4-cff5ace6d2b2

Desktop (please complete the following information):

  • OS: MacOS
  • Browser: Firefox, Safari

Additional context
If I remove increaseViewportBy then it works the first time I do prepend, but if I then manually scroll to the top of the list and do prepend again, then it fails even without defining increaseViewportBy.

@danielsantiago danielsantiago added the bug Something isn't working label Jul 12, 2023
@danielsantiago
Copy link
Author

For reference, I did a hack or workaround adding a ResizeObserver before doing prepend to do the correct scroll top calculation.

https://codesandbox.io/s/sandpack-project-forked-sqjxcj?file=/App.js

@petyosi petyosi self-assigned this Jul 13, 2023
@petyosi
Copy link
Owner

petyosi commented Jul 13, 2023

Confirming, the problem is related to increaseViewportBy. This should work, I will look for a fix.

@petyosi petyosi changed the title [BUG] Scroll position change when prepending one item of unknown height (without scrolling) [BUG] Scroll position change when prepending one item of unknown height with increaseViewportBy Jul 13, 2023
@dinhtheloc
Copy link

Has anyone got a solution to this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants