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] Remove use of row.id when id prop is available #1371

Merged
merged 1 commit into from Apr 12, 2021

Conversation

m4theushw
Copy link
Member

@m4theushw m4theushw commented Apr 7, 2021

Related to #1119, #1200, #1315

This is the first batch of changes to satisfy the need of removing id from the rowData. In this PR I'm replacing row.id with the id prop in all places where it's already available. It has no breaking changes. In the next PR I'll do the rest of the work that requires changes in the API too.

return sortedIds.reduce((res, id) => {
res[id] = idRowsLookup[id];
return res;
}, {} as Record<GridRowId, GridRowModel>);
Copy link
Member

Choose a reason for hiding this comment

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

same here. not sure why you refactored the return type

@dtassone
Copy link
Member

dtassone commented Apr 7, 2021

Not entirely sure how useGridRowId would fit in.
But happy to see it through if it improves the architecture.

@m4theushw m4theushw changed the title [DataGrid] Remove row cloning when getRowId prop is used [DataGrid] Remove use of row.id when id prop is available Apr 7, 2021
@m4theushw m4theushw marked this pull request as ready for review April 7, 2021 17:55
@oliviertassinari oliviertassinari added component: data grid This is the name of the generic UI component, not the React module! core Infrastructure work going on behind the scenes labels Apr 8, 2021
@m4theushw m4theushw requested a review from dtassone April 9, 2021 15:27
@@ -60,6 +60,7 @@ export const GridViewport: ViewportType = React.forwardRef<HTMLDivElement, {}>(
<GridRowCells
columns={visibleColumns}
row={r}
Copy link
Member

Choose a reason for hiding this comment

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

could we cleanup here please? row?

Copy link
Member Author

Choose a reason for hiding this comment

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

@@ -60,6 +60,7 @@ export const GridViewport: ViewportType = React.forwardRef<HTMLDivElement, {}>(
<GridRowCells
columns={visibleColumns}
row={r}
id={r.id}
Copy link
Member

Choose a reason for hiding this comment

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

Would that one change with the next PR?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, the next PR changes to get the id from the Map.

@@ -20,10 +20,15 @@ import { useLogger } from '../../utils/useLogger';
import { useGridState } from '../core/useGridState';
import { getInitialGridRowState, InternalGridRowsState } from './gridRowsState';

// TODO remove after all row.id are removed
export function addGridRowId(rowData: GridRowData, getRowId?: GridRowIdGetter): GridRowModel {
Copy link
Member

Choose a reason for hiding this comment

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

can that one go now?

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 gone in #1377.

@dtassone dtassone merged commit 087fbf9 into mui:master Apr 12, 2021
@m4theushw m4theushw deleted the remove-row-clone branch April 12, 2021 17:11
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! core Infrastructure work going on behind the scenes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants