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] Invert generic parameters order #6874

Merged
merged 6 commits into from
Jan 3, 2023

Conversation

DanailH
Copy link
Member

@DanailH DanailH commented Nov 16, 2022

Fixes #5603

@DanailH DanailH added breaking change component: data grid This is the name of the generic UI component, not the React module! labels Nov 16, 2022
@DanailH DanailH self-assigned this Nov 16, 2022
@mui-bot
Copy link

mui-bot commented Nov 16, 2022

Messages
📖 Netlify deploy preview: https://deploy-preview-6874--material-ui-x.netlify.app/

These are the results for the performance tests:

Test case Unit Min Max Median Mean σ
Filter 100k rows ms 755.7 1,083.6 755.7 887.52 145.169
Sort 100k rows ms 717.4 1,301.9 1,301.9 1,046.26 193.642
Select 100k rows ms 218.1 317.1 303.1 286.96 35.474
Deselect 100k rows ms 161.7 304.3 257.1 247.42 48.006

Generated by 🚫 dangerJS against 06b7855

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.

Could you update the migration guide with the breaking changes and the PR description for the release? This is a very impactful change.

I noticed that valueGetter should also be updated.

diff --git a/packages/grid/x-data-grid/src/models/colDef/gridColDef.ts b/packages/grid/x-data-grid/src/models/colDef/gridColDef.ts
index 9d37447ae..e39515cc1 100644
--- a/packages/grid/x-data-grid/src/models/colDef/gridColDef.ts
+++ b/packages/grid/x-data-grid/src/models/colDef/gridColDef.ts
@@ -128,7 +128,7 @@ export interface GridColDef<R extends GridValidRowModel = any, V = any, F = V> {
    * @param {GridValueGetterParams<any, R>} params Object containing parameters for the getter.
    * @returns {V} The cell value.
    */
-  valueGetter?: (params: GridValueGetterParams<any, R>) => V;
+  valueGetter?: (params: GridValueGetterParams<R, any>) => V;
   /**
    * Function that allows to customize how the entered value is stored in the row.
    * It only works with cell/row editing.

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Dec 14, 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 Dec 22, 2022
@DanailH
Copy link
Member Author

DanailH commented Dec 22, 2022

Could you update the migration guide with the breaking changes and the PR description for the release? This is a very impactful change.

@m4theushw what would be the best way to describe the change in the migration guide?

@m4theushw
Copy link
Member

what would be the best way to describe the change in the migration guide?

The main part is to tell that they need to provide values for 2 generic arguments before the argument that they already have. I checked the TypeScript tests and we could borrow some example from there, like

-renderCell: (params: GridRenderCellParams<number>) => {
+renderCell: (params: GridRenderCellParams<any, any, number>) => {

@DanailH
Copy link
Member Author

DanailH commented Dec 23, 2022

@m4theushw I've updated the guide, if you can check it that would be great.

packages/grid/x-data-grid/src/models/colDef/gridColDef.ts Outdated Show resolved Hide resolved
@@ -7,7 +7,7 @@ import ListItemIcon from '@mui/material/ListItemIcon';
import ListItemText from '@mui/material/ListItemText';
import { INCOTERM_OPTIONS } from '../services/static-data';

function EditIncoterm(props: GridRenderEditCellParams<string | null>) {
function EditIncoterm(props: GridRenderEditCellParams<any, string | null>) {
Copy link
Member

Choose a reason for hiding this comment

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

What is the motivation behind inverting generics' order?
I feel like in GridRenderEditCellParams specifically the V generic is the most useful, and because R is now first - we have to pass any everywhere. The DX feels a bit awkward

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's mainly for consistency. Others were typed in a similar manner.

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

github-actions bot commented Jan 2, 2023

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 3, 2023
@DanailH DanailH requested a review from cherniavskii January 3, 2023 10:39
@DanailH DanailH merged commit e352118 into mui:next Jan 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change 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.

[data grid] Invert generic parameter order in Grid params
5 participants