Skip to content

Commit

Permalink
[DataGridPro] Use readonly array result for getTreeDataPath.
Browse files Browse the repository at this point in the history
We do not try to modify the array after receiving it, so let's accept an immutable array.
This is still compatible with existing usage of getTreeDataPath.
  • Loading branch information
pcorpet committed Apr 26, 2024
1 parent dd20afe commit 857d7f2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/x-data-grid-pro/src/models/dataGridProProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export interface DataGridProPropsWithoutDefaultValue<R extends GridValidRowModel
* @param {R} row The row from which we want the path.
* @returns {string[]} The path to the row.
*/
getTreeDataPath?: (row: R) => string[];
getTreeDataPath?: (row: R) => ReadonlyArray<string>;
/**
* Callback fired when scrolling to the bottom of the grid viewport.
* @param {GridRowScrollEndParams} params With all properties from [[GridRowScrollEndParams]].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ describe('<DataGridPro /> - Tree data', () => {
]);
setProps({
getTreeDataPath: (row) => [...row.name.split('.').reverse()],
} as DataGridProProps);
} as Pick<DataGridProProps, 'getTreeDataPath'>);
expect(getColumnValues(1)).to.deep.equal([
'A',
'A.A',
Expand Down

0 comments on commit 857d7f2

Please sign in to comment.