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] Should not crash when a sort item uses a non-existing column #3224

Merged

Conversation

flaviendelangle
Copy link
Member

@flaviendelangle flaviendelangle commented Nov 19, 2021

Fixes #3020
It unifies the behavior with the filter. If we have an item that uses a non-existing column, we just ignore it.
This is necessary when the sortModel is controlled. When we change the columns, we automatically clean the sortModel. But when it is controlled, the update can be async and occurs after the applySorting triggered by the row change. So we have an applySorting with the new columns but the old sortModel, which causes a crash.

Before: https://codesandbox.io/s/datagriddemo-material-demo-forked-r27yc?file=/demo.tsx

@flaviendelangle flaviendelangle self-assigned this Nov 19, 2021
@@ -164,7 +164,6 @@
{ "name": "GridEnrichedColDef", "kind": "Type alias" },
{ "name": "GridExportFormat", "kind": "Type alias" },
{ "name": "GridFeatureMode", "kind": "Type alias" },
{ "name": "GridFieldComparatorList", "kind": "Type alias" },
Copy link
Member Author

Choose a reason for hiding this comment

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

It is an internal type never used in anything exported.

@flaviendelangle flaviendelangle added bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! labels Nov 23, 2021
@flaviendelangle flaviendelangle merged commit c7efda7 into mui:master Dec 3, 2021
@flaviendelangle flaviendelangle deleted the sort-control-new-dataset branch December 3, 2021 08:23
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] Changing columns when using sortModel throws exception if the previously sorted column is missing
2 participants