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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DataGrid] Fix scroll jump when holding down arrow keys #15164

Merged
merged 2 commits into from
Oct 29, 2024

Conversation

arminmeh
Copy link
Contributor

@arminmeh arminmeh commented Oct 29, 2024

Fixes #15158

Reverts #14888 (which tried to fix another regression)

Scrollbar scroll positions are not set directly anymore as they are not the same number (heights of scroller and scrollbar do not match)
With smaller offsets from the top the difference is minimal, but it grows over time which is why the issue can be observed after a bit of scrolling.
The original code also impacts the performance as the values are recalculated a lot more than before the change. All this lead me to revert everything back to the state prior to #14877.

This brought back the very first issue in the chain.

I found out that it is actually caused because of a stale value in lastPosition.
Following steps in #14830 sets the lock in onScrollbarScroll, which prevents any code being executed in onScrollerScroll so the lastPosition keeps the old value. Calling scrollToIndexes end up eventually in onScrollerScroll, but it does not see the position changed, preventing the scrollbar position change as well.

So, after all these updates, the only actual change is moving up the lastPosition.current = scroller[propertyScroll]; assignment.

Internal scrollbar references are still there (comparing to the code prior to all changes), but they could be useful in future. If there are objections, I can remove them as well.

Following issues should not appear anymore
#15158
#14877 (comment)
#14830

Before: https://codesandbox.io/p/sandbox/scroll-jump-before-2fdm8g
After: https://codesandbox.io/p/sandbox/scroll-jump-after-jvv95x

@arminmeh arminmeh added component: data grid This is the name of the generic UI component, not the React module! regression A bug, but worse labels Oct 29, 2024
@arminmeh arminmeh requested a review from a team October 29, 2024 12:05
@mui-bot
Copy link

mui-bot commented Oct 29, 2024

Deploy preview: https://deploy-preview-15164--material-ui-x.netlify.app/

Generated by 🚫 dangerJS against 47ae82c

@arminmeh arminmeh added the needs cherry-pick The PR should be cherry-picked to master after merge label Oct 29, 2024
Copy link
Member

@KenanYusuf KenanYusuf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the context, changes lgtm.

@arminmeh arminmeh merged commit 48ec9c9 into mui:master Oct 29, 2024
24 checks passed
@arminmeh arminmeh deleted the scroll-jump-with-down-arrow branch October 30, 2024 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: data grid This is the name of the generic UI component, not the React module! needs cherry-pick The PR should be cherry-picked to master after merge regression A bug, but worse
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[DataGrid] Scroll starts jumping back up when holding down arrow keys
3 participants