-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[DataGrid] Improve the invalid sortModel
and filterModel
warnings
#3671
Conversation
sortModel
and filterModel
warnings
These are the results for the performance tests:
|
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.
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).
packages/grid/x-data-grid/src/tests/filtering.DataGrid.test.tsx
Outdated
Show resolved
Hide resolved
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
packages/grid/_modules_/grid/hooks/features/filter/gridFilterUtils.ts
Outdated
Show resolved
Hide resolved
packages/grid/_modules_/grid/hooks/features/filter/useGridFilter.ts
Outdated
Show resolved
Hide resolved
packages/grid/_modules_/grid/hooks/features/sorting/gridSortingUtils.ts
Outdated
Show resolved
Hide resolved
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
packages/grid/_modules_/grid/hooks/features/sorting/gridSortingUtils.ts
Outdated
Show resolved
Hide resolved
packages/grid/_modules_/grid/hooks/features/filter/gridFilterUtils.ts
Outdated
Show resolved
Hide resolved
filterModelMissingItemIdWarning(); | ||
} | ||
|
||
if (hasItemWithoutOperator || hasItemsWithoutIds) { |
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.
Should we make operatorValue
required in v6? If yes, then makes sense to also add a warning for it.
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.
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
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.
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
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.
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
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.
I added a line in Preparing v6 such that we don't forget it
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.
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.
packages/grid/_modules_/grid/hooks/features/filter/gridFilterUtils.ts
Outdated
Show resolved
Hide resolved
packages/grid/_modules_/grid/hooks/features/filter/gridFilterUtils.ts
Outdated
Show resolved
Hide resolved
…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>
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
67644e0
to
7ec1516
Compare
923f63f
to
a5b545b
Compare
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
andtoErrorDev
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
filterModel
andsortModel