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] Add missing api
property to GridCallbackDetails
#12742
Conversation
Deploy preview: https://deploy-preview-12742--material-ui-x.netlify.app/ |
/** | ||
* GridApi that let you manipulate the grid. | ||
*/ | ||
api?: GridApiCommunity; |
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.
Not sure if we should add the typing or remove the field. Also I don't love too much having optional fields, it doesn't seem very clear for an external user if they should expect an API object or not. I've tagged the rest of the team for review, let's see what they think.
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 think we should make the api
required.
We used to pass it conditionally because apiRef
was a Pro feature back then.
It's no longer the case – the apiRef
is available in every plan.
diff --git a/packages/x-data-grid/src/hooks/core/useGridStateInitialization.ts b/packages/x-data-grid/src/hooks/core/useGridStateInitialization.ts
index 860d4d505..0ab86b644 100644
--- a/packages/x-data-grid/src/hooks/core/useGridStateInitialization.ts
+++ b/packages/x-data-grid/src/hooks/core/useGridStateInitialization.ts
@@ -92,11 +92,7 @@ export const useGridStateInitialization = <PrivateApi extends GridPrivateApiComm
const model = controlState.stateSelector(newState, apiRef.current.instanceId);
if (controlState.propOnChange && hasPropChanged) {
- const details =
- props.signature === GridSignature.DataGridPro
- ? { api: apiRef.current, reason }
- : { reason };
- controlState.propOnChange(model, details);
+ controlState.propOnChange(model, { api: apiRef.current, reason });
}
…55/mui-x into fix-call-back-details-type
/** | ||
* GridApi that let you manipulate the grid. | ||
*/ | ||
api: GridApiCommunity; |
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.
Sidenote but I don't like that we don't have a strict convention of either always apiRef
or always api
. Sometimes we need to do awkward conversions like { current: api }
to create a new "ref".
api
property to GridCallbackDetails
closes: #12464