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 Jul 18, 2024
1 parent 8534f2d commit 7cc32b1
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 @@ -153,7 +153,7 @@ interface DataGridProRegularProps<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) => readonly string[];
}

export interface DataGridProPropsWithoutDefaultValue<R extends GridValidRowModel = any>
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 7cc32b1

Please sign in to comment.