-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[DataGrid] Add reason
to onFilterModelChange
#4938
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
Conversation
These are the results for the performance tests:
|
/** | ||
* Additional details passed to the callbacks | ||
*/ | ||
export interface GridCallbackDetails { | ||
export interface GridCallbackDetails<K extends keyof GridControlledStateReasonLookup = any> { |
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.
Once apiRef.current.unstable_updateControlState
stops being only a wrapper for setState
we can replace the any
with the correct types. The any
is necessary because we don't know which key of the state was changed to match with GridControlledStateReasonLookup
.
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. |
Fixes #1803
Always when someone asks how to know why a specific model has changed, we suggest to pass a
reason
argument. We had a few moments where this suggestion was brought: #3516 (comment), #4160 (comment), #1803 (comment), #1141 (comment). This PR implements the foundation to pass areason
param to the callback props and the events published by the controllable states. To give a concrete example, I added it toonFilterModelChange
but the other states will also receive it in follow-up PRs.The high number of files changed is because I renamed the method below. The "update" word didn't make sense where it was being used, but I needed it for the new
unstable_updateControlState
.From now on, to update a sub-state that is controlled (e.g. filtering) we need to use
unstable_updateControlState
instead ofsetState
. This new method has the reason argument and correctly types the options available. In the future,setState
will be used only for non-controlled states.