react-virtualized icon indicating copy to clipboard operation
react-virtualized copied to clipboard

scroll up an infiniteLoader that has scrollToIndex set bounces back to scrollToIndex

Open dcolens opened this issue 8 years ago β€’ 16 comments

repro steps:

  • have an infiniteloader with a list (or grid or ...) with scrollToIndex set to something like 10000 => the list shows starting at the corresponding line
  • scroll back up
  • after a few lines the list jumps back to 10000 (only a few lines for Firefox, a bit more for Chrome) => this is only triggered when fresh data is loaded.

some investigation:

It looks very similar to https://github.com/bvaughn/react-virtualized/issues/595:

recomputeGridSize is called by InfiniteLoader once its new rows load. This in turn sets the _recomputeScrollTopFlag flag to true.

_recomputeScrollTopFlag is set to true in recomputeGridSize as follow:

this._recomputeScrollTopFlag = scrollToRow >= 0 && rowIndex <= scrollToRow;

I'm suspecting that this code is only valid when scrolling down but not up. If this is correct, recomputeGridSize should use this.state.scrollDirectionVertical to compute _recomputeScrollTopFlag and the same issue likely applies to horizontal scrolling too.

dcolens avatar Feb 02 '18 14:02 dcolens

Interested in contributing a new unit test that captures this behavior?

Better yet, a new test and a fix? πŸ˜„

bvaughn avatar Feb 03 '18 16:02 bvaughn

Yes, actually I have a fix (because I hit this in an app I develop). I also looked at the tests, I'm not too sure how to best test this ? Suggestions are welcome 😊

Did

⁣Sent from BlueMail ​

On 3 Feb 2018, 17:36, at 17:36, Brian Vaughn [email protected] wrote:

Interested in contributing a new unit test that captures this behavior?

Better yet, a new test and a fix? πŸ˜„

-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/bvaughn/react-virtualized/issues/998#issuecomment-362830710

dcolens avatar Feb 04 '18 10:02 dcolens

Look at the existing tests. There are many. Should be plenty of examples of testing the individual things your bug report mentions.

Comment out your fix. Write a test that fails. Uncomment your fix and make sure the test passes. πŸ™‚

You're obviously welcome to submit just the fix, but it has a better chance of getting merged (and would really help us out) is there was a test too.

bvaughn avatar Feb 04 '18 15:02 bvaughn

I was asked to write a fix, I did it. I was asked to write tests, I did it.

I think I played fair. Not very motivating to contribute more.

dcolens avatar May 23 '18 11:05 dcolens

@dcolens The reason it was reverted was because the test failed after Grid was updated to use gDSFP

Its on my list of TODOs. However, if you wan't to take some time to fix the test that is failing that'll be welcome :)

wuweiweiwu avatar May 29 '18 07:05 wuweiweiwu

@wuweiweiwu Hi, it seems like people are too busy to fix this bug. I create https://github.com/bvaughn/react-virtualized/pull/1154 with fixed tests.

mengdage avatar Jun 25 '18 18:06 mengdage

@mengdage awesome! Ill take a look tonight!

wuweiweiwu avatar Jun 27 '18 01:06 wuweiweiwu

the merge was reverted - still having the issue - any workarounds known here?

marsch avatar Jun 28 '19 12:06 marsch

Facing the same issue. Any potential workarounds?

wazcodez avatar Jul 20 '19 07:07 wazcodez

Same issue for me.

ryanwilliamquinn avatar Aug 08 '19 20:08 ryanwilliamquinn

Same issue for me too. InfiniteLoader + WindowScroller + Grid

jayeshpp avatar Sep 10 '19 13:09 jayeshpp

Experiencing the same issue. Why was the merge reverted?

bobalazek avatar Sep 18 '19 15:09 bobalazek

For me downgrading to 9.20.0 worked

AleshaOleg avatar Jan 15 '20 18:01 AleshaOleg

Still have this issue InifiteLoader + List in version 9.21.0. @bvaughn is there a walkarounds?

wangbigmountain avatar Mar 11 '20 19:03 wangbigmountain

@bvaughn Facing the same issue with InfinitLoader and Grid with 9.21.2, it would be amazing if this issue could be fixed.

automatication avatar May 16 '20 20:05 automatication

A tiny workaround

I was facing the same issue. I had to render 9k rows in total with a seek functionality for a particular row of interest. After seeking, scrolling up caused no issues, whereas when scrolling down, it automatically jumped to the already seeked row. (I am passing a state parameter to scrollToIndex prop which I am changing so that might rerender the list, but I could not explain why the issue does not come when scrolling up)
I solved the problem by resetting the scrollToIndex once scroll is complete.

this.setState({scrolled_index: index  + 20},  //this centers the row for my use case.    
          () =>{    
            this.setState({scrolled_index: -1})    
          });

I am passing this.state.scrolled_index to the List component. I am currently working in a project with deadlines. Will get a plunker up and running as soon as possible. Will love to see a fix for this issue.

gigatesseract avatar May 24 '20 06:05 gigatesseract