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] Improve the invalid sortModel and filterModel warnings #3671

Merged
merged 32 commits into from
Feb 15, 2022

Conversation

flaviendelangle
Copy link
Member

@flaviendelangle flaviendelangle commented Jan 20, 2022

Part of #3166

For the filtering, we were not blocking the initialization with several items.
For the sorting, we were not blocking neither the initialization nor the control pattern with several items, nor the apiRef call.

I did a console.warn instead of throwing because I can't figure out how to catch the error in the test.
to.throw and toErrorDev don't work when the error is inside a render, and I did not find any example on the core to help me.

What's next

  • Improve the proptypes check to check both the control model and the initialState sub-key for filterModel and sortModel

@flaviendelangle flaviendelangle added the component: data grid This is the name of the generic UI component, not the React module! label Jan 20, 2022
@flaviendelangle flaviendelangle self-assigned this Jan 20, 2022
@flaviendelangle flaviendelangle marked this pull request as draft January 20, 2022 10:53
@flaviendelangle flaviendelangle changed the title [DataGrid] Improve the invalid sortModel and filterModel warnings [DataGrid] Improve the invalid sortModel and filterModel warnings Jan 20, 2022
@mui-bot
Copy link

mui-bot commented Jan 20, 2022

These are the results for the performance tests:

Test case Unit Min Max Median Mean σ
Filter 100k rows ms 236.7 386.3 310.2 309.2 54.555
Sort 100k rows ms 458.9 791.9 607.6 623.34 109.587
Select 100k rows ms 139.6 307.5 152.6 182.16 63.128
Deselect 100k rows ms 88 200.2 199.1 159.92 44.273

Generated by 🚫 dangerJS against a5b545b

@flaviendelangle flaviendelangle marked this pull request as ready for review January 21, 2022 10:35
Copy link
Member

@m4theushw m4theushw left a comment

Choose a reason for hiding this comment

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

If you want to throw an error, you can catch it in the test by wrapping the component in an error boundary. You also need to mock console.error to prevent React from logging it.

The prop-types could still be used but it would be better to migrate them to a different file to able to test them with PropTypes.checkPropTypes. I had to remove PropTypes.checkPropTypes in #2395 (comment).

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Jan 26, 2022
@github-actions
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Jan 26, 2022
@github-actions
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Jan 27, 2022
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Jan 28, 2022
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Feb 1, 2022
@github-actions
Copy link

github-actions bot commented Feb 1, 2022

This pull request has conflicts, please resolve those before we can evaluate the pull request.

filterModelMissingItemIdWarning();
}

if (hasItemWithoutOperator || hasItemsWithoutIds) {
Copy link
Member

Choose a reason for hiding this comment

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

Should we make operatorValue required in v6? If yes, then makes sense to also add a warning for it.

Copy link
Member Author

Choose a reason for hiding this comment

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

I would say yes, I don't like when we are doing magic like adding a default operator.

@alexfauquette if you have a thought on this

Copy link
Member

Choose a reason for hiding this comment

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

Yes, we could make it required.

If it does not cause a problem, I would be in favor of keeping the default operator, just to save the ass of developers that miss use the grid in production

Copy link
Member Author

Choose a reason for hiding this comment

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

As I see it, it would be like the ID

  • The typing says it's required
  • If none is provided, we fire a warning and provide a default behavior

Copy link
Member

Choose a reason for hiding this comment

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

I added a line in Preparing v6 such that we don't forget it

Copy link
Member Author

@flaviendelangle flaviendelangle Feb 15, 2022

Choose a reason for hiding this comment

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

I added a warning + doc line

@m4theushw I kept this one as console.warn because other "deprecation" are warning not error.
But we could change all of them.

flaviendelangle and others added 5 commits February 14, 2022 08:40
…gUtils.ts

Co-authored-by: Matheus Wichman <matheushw@outlook.com>
…tils.ts

Co-authored-by: Matheus Wichman <matheushw@outlook.com>
Co-authored-by: Matheus Wichman <matheushw@outlook.com>
@github-actions
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Feb 14, 2022
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Feb 14, 2022
@alexfauquette alexfauquette mentioned this pull request Feb 14, 2022
41 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

None yet

5 participants