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 scrollbar position not being updated after scrollToIndexes #14877

Merged
merged 1 commit into from
Oct 8, 2024

Conversation

arminmeh
Copy link
Contributor

@arminmeh arminmeh commented Oct 8, 2024

Fixes #14830

scrollToIndexes eventually ends up here

if (virtualScrollerRef.current && params.left !== undefined && colRef.current) {
const direction = isRtl ? -1 : 1;
colRef.current.scrollLeft = params.left;
virtualScrollerRef.current.scrollLeft = direction * params.left;
logger.debug(`Scrolling left: ${params.left}`);
}

virtualScroller gets the update and the scrollbar follows via an event listener

In this scenario, only scrollbar should be updated, since this was already done for the scroller. it looks like that, in some cases, scroller event gets executed first and it locks scrollbar update with the isLocked flag set to true.

I have changed this to work with the last position (it was already used in one event listener). This means that the event listeners will run as long as the elements are not at the right position.

As mentioned in the issue, it was already really hard to reproduce the bug, but I notice that after update, the scrollbar gets rendered and displayed after every click, while before it would update in the background.

Before: https://codesandbox.io/p/sandbox/trusting-night-rcm484
After: https://codesandbox.io/p/sandbox/ecstatic-hertz-94g86f

@arminmeh arminmeh added bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! labels Oct 8, 2024
@arminmeh arminmeh requested a review from a team October 8, 2024 12:54
@mui-bot
Copy link

mui-bot commented Oct 8, 2024

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

Generated by 🚫 dangerJS against 6ac90b3

@arminmeh arminmeh force-pushed the horizontal-scrollbar-position branch from b072d21 to 6ac90b3 Compare October 8, 2024 16:52
@cherniavskii
Copy link
Member

cherniavskii commented Oct 8, 2024

@arminmeh Were you able to reproduce this issue? I tried in Chrome and Firefox and the scrolling works as expected.
UPD: I can reproduce it by dragging the scrollbar thumb 👍🏻

Copy link
Member

@cherniavskii cherniavskii left a comment

Choose a reason for hiding this comment

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

I've updated the PR description with Before/After sandboxes. It looks good to me!

@arminmeh
Copy link
Contributor Author

arminmeh commented Oct 8, 2024

I've updated the PR description with Before/After sandboxes

Thanks @cherniavskii
I don't have access to the "After" sandbox

@arminmeh arminmeh merged commit 018dc1d into mui:master Oct 8, 2024
18 checks passed
@cherniavskii
Copy link
Member

Updated!

Copy link
Member

Choose a reason for hiding this comment

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

@arminmeh I just noticed that this PR introduced a regression: https://deploy-preview-14877--material-ui-x.netlify.app/x/react-data-grid/#premium-plan

Screen.Recording.2024-10-08.at.22.09.55.mov

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll take a look

Copy link
Contributor Author

Choose a reason for hiding this comment

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

arminmeh added a commit to arminmeh/mui-x that referenced this pull request Oct 9, 2024
arminmeh added a commit to arminmeh/mui-x that referenced this pull request Oct 9, 2024
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!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[data grid] Horizontal scrollbar position is not updated after scrollToIndexes
3 participants