scroll up an infiniteLoader that has scrollToIndex set bounces back to scrollToIndex
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.
Interested in contributing a new unit test that captures this behavior?
Better yet, a new test and a fix? π
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
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.
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 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 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 awesome! Ill take a look tonight!
the merge was reverted - still having the issue - any workarounds known here?
Facing the same issue. Any potential workarounds?
Same issue for me.
Same issue for me too. InfiniteLoader + WindowScroller + Grid
Experiencing the same issue. Why was the merge reverted?
For me downgrading to 9.20.0 worked
Still have this issue InifiteLoader + List in version 9.21.0. @bvaughn is there a walkarounds?
@bvaughn Facing the same issue with InfinitLoader and Grid with 9.21.2, it would be amazing if this issue could be fixed.
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.