-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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 error #15521
[DataGrid] Fix scroll error #15521
Conversation
Deploy preview: https://deploy-preview-15521--material-ui-x.netlify.app/ |
@@ -216,9 +216,14 @@ export const useGridVirtualScroller = () => { | |||
); | |||
|
|||
const triggerUpdateRenderContext = useEventCallback(() => { | |||
const scroller = scrollerRef.current; | |||
if (!scroller) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still can't help myself asking if this is not hiding something.
It could be about useTimeout
that uses useOnMount
, that uses useEffect
so call the clear function async, so after the DOM node was unmounted, ref was set to null. Changing useTimeout
to use useLayoutEffect to run clean-up in sync mode could solve this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
after the DOM node was unmounted, ref was set to null
I tried reproducing it #14987 (comment), but I couldn't get any scrolling callbacks called after the grid was unmounted.
top: scrollerRef.current!.scrollTop, | ||
left: scrollerRef.current!.scrollLeft, | ||
top: scroller.scrollTop, | ||
left: scroller.scrollLeft, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The !
type annotation causing yet another bug.
Cherry-pick PRs will be created targeting branches: v7.x |
Fixes #14987 (comment)
I can't reproduce the issue, but early return makes sense here anyway.