Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DataGrid] Virtualization not respecting scrollTop #1911

Closed
2 tasks done
oliviertassinari opened this issue Jun 15, 2021 · 4 comments
Closed
2 tasks done

[DataGrid] Virtualization not respecting scrollTop #1911

oliviertassinari opened this issue Jun 15, 2021 · 4 comments
Labels
bug 馃悰 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! priority: important This change can make a difference

Comments

@oliviertassinari
Copy link
Member

oliviertassinari commented Jun 15, 2021

  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 馃槸

End-users can feel a difference between virtualization enable and disabled. The scrolling experience is not continuous, it jumps. The scroll height is also wrong, it's too short.

Expected Behavior 馃

End-users shouldn't feel any difference between virtualization enable and disabled. Scrolling should be:

Steps to Reproduce 馃暪

Steps:

  1. Open https://codesandbox.io/s/material-uix-gridscroll-to-indexes-demo-simple-forked-on0dc
  2. See how the scroll-top is discontinue disorienting end-users.
    scrollTop

You can also see there is a blank space at the bottom, but it's #414.

Context 馃敠

Raised by @m4theushw in #1871.

I found that the amount of scroll needed to make a row visible is less than what I would normally expect (rowIndex * rowHeight)

It's KO. It would only make sense for this use case: https://ag-grid.com/react-grid/massive-row-count/.

I suspect the best course of action is to rewrite the virtualization logic. Use this as an opportunity to take the following constraints into account in the design.

@oliviertassinari oliviertassinari added bug 馃悰 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! labels Jun 15, 2021
@oliviertassinari
Copy link
Member Author

oliviertassinari commented Jun 16, 2021

Looking at the reproduction, we are completely off. We have 34 rows of 50px height with a viewport of 290px height. So the max scroll top should be = 34 * 50 - 290 = 1410px. Instead, it's 1250px 馃檭.

@m4theushw
Copy link
Member

Looking at the reproduction, we are completely off. We have 34 rows of 50px height with a viewport of 290px height. So the max scroll top should be = 34 * 50 - 290 = 1410px. Instead, it's 1250px 馃檭.

Yeah, when I was playing with the virtualization to understand it I noticed that we use a different calculation for the height of the container. If we do the right thing the user will have to scroll more, but there will be no discontinuation when reaching the top.

There's also a blank space that might appear when calling scrollToIndexes. Making the scrollTop to honor the theoretical position of the row will fix it too. BTW, we could improve this API to allow the user to determine if he wants: 1. scroll as little as possible to make the row visible or 2. scroll as much necessary so the row is at the top of the viewport. AG Grid in ensureIndexVisible even allows to scroll to place the row at the middle or bottom of the viewport.

image

@oliviertassinari
Copy link
Member Author

we could improve this API to allow the user to determine if he wants: 1. scroll as little as possible to make the row visible or 2. scroll as much necessary so the row is at the top of the viewport. AG Grid in ensureIndexVisible even allows to scroll to place the row at the middle or bottom of the viewport.

True, makes me think about the different options of https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView

@m4theushw
Copy link
Member

Fixed by #2673

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 馃悰 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! priority: important This change can make a difference
Projects
None yet
Development

No branches or pull requests

2 participants