bvaughn / react-virtualized

React components for efficiently rendering large lists and tabular data
http://bvaughn.github.io/react-virtualized/
MIT License
26.1k stars 3.05k forks source link

Scroll jumps to the top when List data gets updated. #1755

Open abhijeet-peak opened 2 years ago

abhijeet-peak commented 2 years ago

My use case is that I am building a log container to render the logs in the reverse order. Working We fetches the logs in batches. Initially we are fetching the last batch of the log and rendered on the screen. We continuously fetching the older batches of log and update the log array. Irrespective of whether the user are scrolling at the top or not. Issue when ever the log array got updated the scroll position also changed to the top. suppose we fetch logs in the batches of length 10 and only 5 log can be displayed to the user at a time. initially when we fetched the last batch of the log, the initial condition will be logArray = [40, 41 ....50] On UI these 5 logs will be shown [ 40 <- scroll position ... 44 45 ] when the another batch of 10 log get loaded the logArray becomes [30, 31 ....47, 48,49, ....50] and on UI [ 30 <- scroll position ... 34 35 ] So our issue is to restrict the scroll to move at the top at every time logArray gets updated. As it creates a bad user experience if user is reading the middle logs and is taken at the top forcefully.

sharimgwn commented 1 year ago

Did you find a solution? Having a similar need

abhijeet-peak commented 1 year ago

Did you find a solution? Having a similar need

react-virtualized does not support negative indexes. whenever we are appending data in array indices gets updated and scroll points to 0 indices