schrodinger / fixed-data-table-2

A React table component designed to allow presenting millions of rows of data.
http://schrodinger.github.io/fixed-data-table-2/
Other
1.29k stars 289 forks source link

Scroll to an exact position when clicking the scrollbar track doesn't work in case of variable row heights and isVerticalScrollExact = true #711

Closed daniela-mateescu closed 8 months ago

daniela-mateescu commented 10 months ago

When having variable row heights by setting rowHeightGetter property and isVerticalScrollExact = true and clicking once on the vertical scrollbar area, the scrollbar thumb isn't jumping exactly where the click happened.

This was a known issues at the time the "isVerticalScrollExact" feature was introduced: in https://github.com/schrodinger/fixed-data-table-2/pull/701

Possible Solution

The cause of this is that the actual row heights are requested when the first scroll event happens. But in order for the scrollbar to work correctly when is clicked, the exact row heights should be computed before scrollbar initial configuration, in order for the ScrollbarComponent.contentSize to be exact.

So the solution is to move the code that computes and stores the actual row heights from scrollTo() to initializeRowHeightsAndOffsets()

Steps to Reproduce (for bugs)

You can reproduce this by simply checking out the DynamicRowHeights example, specifying isVerticalScrollExact={true}, and scrolling exactly once by clicking on the vertical scrollbar area.

daniela-mateescu commented 10 months ago

Hello!

I have done a fix for this in: https://github.com/schrodinger/fixed-data-table-2/pull/712/. Please let me know if it looks good to you.

Thank you.

pradeepnschrodinger commented 10 months ago

Nice! Thanks for filing and putting a PR so quickly.

cc: @karry08

pradeepnschrodinger commented 8 months ago

I'm closing this out since the fix was released with v2.0.6.