React-virtualized: Scroll stutters/resets when using CellMeasurer with scrollToIndex on a List

Created on 5 Sep 2017  路  4Comments  路  Source: bvaughn/react-virtualized

When using CellMeasurer and scrollToIndex at the same time (on a List), scrolling upward seems to be broken. Explained in more detail here:

https://stackoverflow.com/questions/45993421/react-virtualized-scrolltoindex-not-working-with-cellmeasurer

Plunker:

https://plnkr.co/edit/XPF5D88WI9CErhkmrgAy?p=preview

bug help wanted

Most helpful comment

It actually seems that there are two distinct issues here:

  1. If you scroll upward toward unmeasured cells, then once the cells are measured the cells after them will jump down to accommodate the newly measured cells above them. The severity of the effect is related to the difference between a cell's default size and the actual size. This seems to be a very challenging issue to solve, and I think it's the focus of #610.

  2. Independent of that, when you use the scrollToIndex prop on a list that also uses CellMeasurer, the list seems to repeatedly jump back to the specified index (maybe whenever cells are measured?), as if the list seems to think that the scrollToIndex prop changed (and thus it must scroll to the new value) even though it has not. This issue is briefly mentioned in #610 but is mostly ignored--intuitively it seems like it's probably much easier to solve. At the very least, it seems like we can workaround this issue by calling List.scrollToRow() instead of setting the scrollToIndex prop. Example: https://plnkr.co/edit/8V4AtlqPtELrmDQMgBr7?p=preview (click "CLICK ME" and it will scroll to row 150; then attempt to scroll up and it should work fine).

All 4 comments

610 should be the same problem

It actually seems that there are two distinct issues here:

  1. If you scroll upward toward unmeasured cells, then once the cells are measured the cells after them will jump down to accommodate the newly measured cells above them. The severity of the effect is related to the difference between a cell's default size and the actual size. This seems to be a very challenging issue to solve, and I think it's the focus of #610.

  2. Independent of that, when you use the scrollToIndex prop on a list that also uses CellMeasurer, the list seems to repeatedly jump back to the specified index (maybe whenever cells are measured?), as if the list seems to think that the scrollToIndex prop changed (and thus it must scroll to the new value) even though it has not. This issue is briefly mentioned in #610 but is mostly ignored--intuitively it seems like it's probably much easier to solve. At the very least, it seems like we can workaround this issue by calling List.scrollToRow() instead of setting the scrollToIndex prop. Example: https://plnkr.co/edit/8V4AtlqPtELrmDQMgBr7?p=preview (click "CLICK ME" and it will scroll to row 150; then attempt to scroll up and it should work fine).

Using this for now. Thanks @athorwall

At the very least, it seems like we can workaround this issue by calling List.scrollToRow() instead of setting the scrollToIndex prop

This seems to be another issue that was at least partially addressed in version 20.1. This plunker example:

https://plnkr.co/edit/UDbO2KKjQ3neDok0EOah?p=preview

is a fork of the example mentioned above, but with updated React and RV libraries. It seems to work unless the RV version is 20.0 or less.

Are there still cases that are not working with a current version of RV?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

johnnyji picture johnnyji  路  3Comments

hyeminHwang picture hyeminHwang  路  3Comments

mccambridge picture mccambridge  路  3Comments

ms007 picture ms007  路  4Comments

wnz99 picture wnz99  路  3Comments