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

fast scrolling in InfiniteLoader scrolls back to top after data is loaded

Open XeniaSiskaki opened this issue 9 years ago • 10 comments

I am using an InfiniteLoader with a Table and the problem I'm having is the following: when I move the scrollbar to the end quickly (or an index where data is not yet loaded), it scrolls back to the top after data is loaded. This problem can also be observed in the demo example here

XeniaSiskaki avatar Feb 24 '17 09:02 XeniaSiskaki

+1

vsromanc avatar Feb 24 '17 13:02 vsromanc

Ooh, nice bug report.

bvaughn avatar Feb 25 '17 16:02 bvaughn

Looks like it's not specific to Table (which makes sense considering Table and List both use Grid internally). Adding some logging, I see that Grid is getting a "scroll" event with scrollTop:0 for some reason.

Edit 1: Looks like _updateScrollTopForScrollToRow is setting state.scrollTop to 0 for some reason, which causes componentDidUpdate to then scroll the DOM node back to 0 as well.

bvaughn avatar Feb 25 '17 16:02 bvaughn

This looks like something introduced by me recently when I added support for the new async CellMeasurer to Grid. (Sorry!) recomputeGridSize is called by InfiniteLoader once its new rows load. This in turn sets the _recomputeScrollTopFlag flag which causes the chain of methods I mentioned above to be invoked.

This shouldn't matter, since _updateScrollTopForScrollToRow short-circuits if the user hasn't actually specified a scrollToRow- or at least it attempts to 😅 but in this case scrollToRow is null (because of an old, unused state prop in my example) and null >= 0 is true 🤡.

I have to run to an appointment now but the fix for this is simple. I just want to make sure I added at least one regression test first. I'll get it done sometime this morning/afternoon.

bvaughn avatar Feb 25 '17 16:02 bvaughn

Fixed in 2176a5f. Will go out in 9.1.0 shortly.

bvaughn avatar Feb 25 '17 19:02 bvaughn

Super! Will test it when it's out

XeniaSiskaki avatar Feb 27 '17 07:02 XeniaSiskaki

It was released with 9.1.0 yesterday.

bvaughn avatar Feb 27 '17 07:02 bvaughn

It seems that this is still happening. Using WindowScroller, InfinitedLoader, Autosizer and List

nicolasletoublon avatar Aug 05 '22 15:08 nicolasletoublon

may I know any workaround on it ?

vn425282 avatar Nov 04 '22 10:11 vn425282

@vn425282 @nicolasletoublon I am guessing you guys don't have a skeleton and are just rendering null in renderActionRow when there is nothing to render.

HarvWorks avatar May 02 '24 14:05 HarvWorks