-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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] Spotting perf issues #501
Conversation
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 tests surface a regression, sorting is no longer working on the first click. You can reproduce on https://deploy-preview-501--material-ui-x.netlify.app/components/data-grid/rows/#basic-sorting. It's actually great that we are doing this refactorization, each bug is an opportunity to add a new test case.
I had the same problem after I removed the |
f49ae00
to
a97e3e7
Compare
Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com>
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.
fix an issue with the sorting
Is the bug something we can/should add a test case for?
We already have tests for sorting. It was just small display issue.
packages/grid/_modules_/grid/models/params/rowSelectedParams.ts
Outdated
Show resolved
Hide resolved
packages/grid/_modules_/grid/models/colDef/checkboxSelection.tsx
Outdated
Show resolved
Hide resolved
Any idea @oliviertassinari why karma is not happy? Or is it just personal 😛 |
Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com>
I'm looking at it. Something prevents the test to complete it. |
I could pinpoint the test that fails. it's: It freezes on the selection click event. |
There are two problems:
diff --git a/packages/grid/x-grid/src/XGrid.test.tsx b/packages/grid/x-grid/src/XGrid.test.tsx
index b5da9b88..a7e9c0f4 100644
--- a/packages/grid/x-grid/src/XGrid.test.tsx
+++ b/packages/grid/x-grid/src/XGrid.test.tsx
@@ -189,7 +189,7 @@ describe('<XGrid />', () => {
});
describe('prop: checkboxSelection', () => {
- it('should check and uncheck when double clicking the row', async () => {
+ it.only('should check and uncheck when double clicking the row', async () => {
render(
<div style={{ width: 300, height: 300 }}>
<XGrid
@@ -213,10 +213,12 @@ describe('<XGrid />', () => {
expect(checkbox).to.have.property('checked', false);
fireEvent.click(screen.getByRole('cell', { name: 'Nike' }));
+ await raf();
expect(row).to.have.class('Mui-selected');
expect(checkbox).to.have.property('checked', true);
fireEvent.click(screen.getByRole('cell', { name: 'Nike' }));
+ await raf();
expect(row).to.not.have.class('Mui-selected');
expect(checkbox).to.have.property('checked', false);
});
diff --git a/packages/grid/x-grid/src/XGrid.test.tsx b/packages/grid/x-grid/src/XGrid.test.tsx
index b5da9b88..5c1f4a08 100644
--- a/packages/grid/x-grid/src/XGrid.test.tsx
+++ b/packages/grid/x-grid/src/XGrid.test.tsx
@@ -189,7 +189,7 @@ describe('<XGrid />', () => {
});
describe('prop: checkboxSelection', () => {
- it('should check and uncheck when double clicking the row', async () => {
+ it.only('should check and uncheck when double clicking the row', async () => {
render(
<div style={{ width: 300, height: 300 }}>
<XGrid
@@ -213,11 +213,11 @@ describe('<XGrid />', () => {
expect(checkbox).to.have.property('checked', false);
fireEvent.click(screen.getByRole('cell', { name: 'Nike' }));
- expect(row).to.have.class('Mui-selected');
+ expect(row!.classList.contains('Mui-selected')).to.equal(true);
expect(checkbox).to.have.property('checked', true);
fireEvent.click(screen.getByRole('cell', { name: 'Nike' }));
- expect(row).to.not.have.class('Mui-selected');
+ expect(row!.classList.contains('Mui-selected')).to.equal(false);
expect(checkbox).to.have.property('checked', false);
});
}); |
|
We can investigate more if it reproduces more often. |
Why would it rely on requestAnimationFrame? |
…into useSelectionPerf
* spotting perf issues * refactor selection * prettier * cleanup * fix header rendering and sorting * cleanup * Apply suggestions from code review Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com> * small refactoring * prettier * lint * cleanup * Update packages/grid/_modules_/grid/models/params/rowSelectedParams.ts Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com> * Fix tests Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com>
This PR aims to