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 container width change on React 18 #5566

Merged
merged 1 commit into from
Jul 22, 2022

Conversation

m4theushw
Copy link
Member

@m4theushw m4theushw commented Jul 22, 2022

Fixes #5085

Related to #5192

I saw this bug when working in #4155 and one of the tests was failing with React 18 but passing with React 17. By debugging, I noticed that rootRef.current was null when the resize event is fired. I suppose this is happening because the event is triggered while the ref is unmounted. With React 17, the event is fired after the ref is mounted.

Before: https://codesandbox.io/s/datagriddemo-demo-mui-x-forked-hw2hd1?file=/demo.tsx
After: https://codesandbox.io/s/datagriddemo-demo-mui-x-forked-s2p48r?file=/package.json

How to reproduce:

msedge_bl8ELjzZqH

@m4theushw m4theushw added bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! labels Jul 22, 2022
@mui-bot
Copy link

mui-bot commented Jul 22, 2022

These are the results for the performance tests:

Test case Unit Min Max Median Mean σ
Filter 100k rows ms 251.3 429.5 367.9 339.04 73.904
Sort 100k rows ms 477 856.1 674.8 674.18 125.473
Select 100k rows ms 151.4 259.3 221.2 214.08 34.894
Deselect 100k rows ms 116 202.8 175.5 164.96 35.73

Generated by 🚫 dangerJS against 0d45381

Comment on lines -64 to -65
stub(window, 'requestAnimationFrame').callsFake((fn: any) => fn());
stub(window, 'cancelAnimationFrame');
Copy link
Member Author

Choose a reason for hiding this comment

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

Mocking requestAnimationFrame doesn't feel right so I inverted the logic: use real clock by default and fake clock on demand.

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.

Nice!

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.

[DataGrid] tabs switching breaks DataGrid columns.
3 participants