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] Make GRID_ROWS_CLEAR private #1925
[DataGrid] Make GRID_ROWS_CLEAR private #1925
Conversation
382439d
to
fb646d9
Compare
I don't think it is dead code at least when I wrote it, it was not. |
packages/grid/_modules_/grid/hooks/features/sorting/useGridSorting.ts
Outdated
Show resolved
Hide resolved
I think the rendering optimisation fixed it |
fb646d9
to
25f20f9
Compare
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 following diff passes on HEAD but here doesn't:
diff --git a/packages/grid/x-grid/src/tests/rows.XGrid.test.tsx b/packages/grid/x-grid/src/tests/rows.XGrid.test.tsx
index c800f9cb..591610b2 100644
--- a/packages/grid/x-grid/src/tests/rows.XGrid.test.tsx
+++ b/packages/grid/x-grid/src/tests/rows.XGrid.test.tsx
@@ -162,6 +162,7 @@ describe('<XGrid /> - Rows', () => {
it('should allow to reset rows with setRows and render after 100ms', () => {
render(<TestCase />);
+ expect(getColumnValues()).to.deep.equal(['Nike', 'Adidas', 'Puma']);
const newRows = [
{
id: 3,
@@ -169,10 +170,9 @@ describe('<XGrid /> - Rows', () => {
},
];
apiRef.current.setRows(newRows);
-
- clock.tick(50);
- expect(getColumnValues()).to.deep.equal(['Nike', 'Adidas', 'Puma']);
- clock.tick(50);
+ // Force an update before the 100ms
+ apiRef.current.forceUpdate(() => apiRef.current.state);
+ clock.tick(100);
expect(getColumnValues()).to.deep.equal(['Asics']);
});
My suggestion is to try to remove the timeout from the custom forceUpdate
in useGridRows
or to reset the sorted rows after updating the rows in this hook (might break the separation of concern).
723d413
to
5ca41e1
Compare
8f8efd4
to
8944040
Compare
@m4theushw Oh wow, great catch. I have added a failing test case to avoid regressions in the future. I have also updated the assertion to illustrate the current behavior. I have reduced the ambition of the changes, I don't have the bandwidth to improve the current state more that this. |
Should we use this PR to rename the event to match the convention CLEARED => CLEAR? |
I'm waiting for #1862 to be merged to rebase. |
8944040
to
92b55a7
Compare
92b55a7
to
1f8609f
Compare
Breaking changes
The
GRID_ROWS_CLEAR
event was always triggered alongsideGRID_ROWS_SET
. You can listen to the latter event only.See the rationale in #1862 (comment). When GRID_ROWS_CLEARED triggers,GRID_ROWS_SET
is also triggered, no need to update the sorting state twice.Note that this makesGRID_ROWS_CLEARED
an orphan, nobody is listening to the event.If I'm missing something and is really required, then it surfaces a hole in the test suite, the CI is green.