bvaughn / react-window

React components for efficiently rendering large lists and tabular data
https://react-window.now.sh/
MIT License
15.54k stars 779 forks source link

Unwanted onScroll trigger for FixedSizeList #699

Open madalina-agh opened 1 year ago

madalina-agh commented 1 year ago

If I have a list with enough elements to be able to scroll, I scroll down and then clear the list, then the onScroll event is triggered after reducing the items number, which shouldn't happen.

I have made an example here where you can see the issue: https://codesandbox.io/s/elastic-bush-o1s8ec?file=/index.js

Replication steps:

  1. Scroll down the list
  2. Click the button "Clear list" to reduce the number of items
  3. An alert is popping out to notify that the onScroll has been triggered and the "Scrolled to the top" criteria is met

Note: as a criteria for scrolling to the top I check for the props to have scrollUpdateWasRequested === false && props.scrollDirection === "backward" && props.scrollOffset === 0

tomfridental1 commented 1 year ago

Same here