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

Scroll up issues with cell measure

Open muthu32 opened this issue 7 years ago • 7 comments

What is the current behavior?

When table element has scrollToIndex and image measure, then scroll up jumps to scrolltoindex position.

What is the expected behavior?

Scroll up should work without jump like scroll down

Example Repo

https://codepen.io/muthu32/pen/pmygmR

muthu32 avatar Jun 18 '19 05:06 muthu32

What is the current behavior?

The same issue as above but with a list element. When a scrollToIndex has been specified and is no longer visible, the scroll will jump. In the example above, it happens for scrolling both up and down, which is the same as what I'm experiencing.

What is the expected behavior?

It seems that scrollToIndex will force you to go back to specified index if it isn't visible. I would like the behavior to be like the example here, list element demo. In that list, you can specify an index to be scrolled to, but then interact with the list normally.

dcjones1 avatar Jun 21 '19 15:06 dcjones1

To add on, it seems like this is related to the cached row height. When I manually input a value, the list seems to work as expected. In the demo, it looks like the row height isn't being calculated.

dcjones1 avatar Jun 21 '19 16:06 dcjones1

There is a problem with image measure that force you to jump up. When I analysed the source code following lines are found to be responsible for jump to scroll to index position.

https://github.com/bvaughn/react-virtualized/blob/bc5ae2fa084e20323b445b31fd72acee90e0ab5f/source/CellMeasurer/CellMeasurer.js#L141-L144

https://github.com/bvaughn/react-virtualized/blob/bc5ae2fa084e20323b445b31fd72acee90e0ab5f/source/Grid/Grid.js#L554-L558

When I removed those specified lines from Grid.js, it works fine.

muthu32 avatar Jun 22 '19 05:06 muthu32

Facing the same issue - is there a way to know once ScrollToIndex is applied, so it can be set to undefined for any subsequent scroll event.

wazcodez avatar Jul 20 '19 07:07 wazcodez

I found that using the this.list.scrollToRow(row) on the componentDidMount works better than the scrollToIndex on the component

benoist avatar Sep 10 '19 11:09 benoist

I just added an onScroll handler that ended up setting my scrollToIndex back to undefined, tiny workaround

comfroels avatar Dec 09 '19 16:12 comfroels

This is addressed in react-virtualized 10 (upcoming). Table's scrollToIndex prop is replaced by tableRef.current.scrollToRow({ index }), which is a one-time scroll, so images measured while scrolling up no longer make it jump back.

bvaughn avatar Oct 18 '26 14:10 bvaughn