bvaughn / react-virtualized

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

Slight scroll up using mouse wheel makes highlighted list item to force scroll into view #1265

Open OmkarRajam opened 5 years ago

OmkarRajam commented 5 years ago

What's the issue: When we scroll down the list for some time and then we scroll up even for a bit (using mouse wheen/touchpad), we jump to the highlighted list item (highlighted item is force scrolled in the view) even though it was far away from where we were.

When does the issue occur: This is a rare issue which occurs only when all these conditions are met

  1. list items height is variable (thus we use CellMeasurer),
  2. we have used Arrow Key Stepper, (and we maintain a scrollToIndex state)
  3. height of list item changes after it is mounted. (we fetch some data once the component is mounted and then to accommodate the new height, 'measure' function is called once data is received.)

here's a gif: scroll_jump

You can see a demo of the above problem on this codesandbox https://codesandbox.io/s/github/OmkarRajam/react_virtualized_pr It has been created using this repository https://github.com/OmkarRajam/react_virtualized_pr

Browser Chrome
OS Windows
React 16.6.0
React DOM 16.6.0
react-virtualized 9.21.0

I was able to fix this issue by doing a minor change as proposed in this PR: #1266 If this fix is correct, I request you to accept the above PR which focuses on solving this issue.

OmkarRajam commented 5 years ago

I was able to fix this issue by doing a minor change as proposed in this PR: #1266 If this fix is correct, I request you to accept the above PR which focuses on solving this issue.

svsool commented 5 years ago

Same problem here with version 9.21.0

svsool commented 5 years ago

I think it should be considered for this._recomputeScrollLeftFlag as well @OmkarRajam

svsool commented 5 years ago

I resolved the problem by using this method manually with ref https://github.com/bvaughn/react-virtualized/blob/2c9934066c6fd8e7135831162d19909ea4c3bb5c/source/List/List.js#L180-L187