@@ -4,8 +4,13 @@ import {
44 gridRowTreeSelector ,
55 gridExpandedSortedRowIdsSelector ,
66 gridRowNodeSelector ,
7+ gridRowMaximumTreeDepthSelector ,
78} from '@mui/x-data-grid-pro' ;
8- import { gridExpandedSortedRowIndexLookupSelector } from '@mui/x-data-grid-pro/internals' ;
9+ import {
10+ gridExpandedSortedRowIndexLookupSelector ,
11+ useGridRowsOverridableMethods as useGridRowsOverridableMethodsCommunity ,
12+ useGridSelector ,
13+ } from '@mui/x-data-grid-pro/internals' ;
914import type { RefObject } from '@mui/x-internals/types' ;
1015import { rowGroupingReorderExecutor } from '../rowReorder/reorderExecutor' ;
1116import type { GridPrivateApiPremium } from '../../../models/gridApiPremium' ;
@@ -17,6 +22,9 @@ export const useGridRowsOverridableMethods = (
1722 props : Pick < DataGridPremiumProcessedProps , 'processRowUpdate' | 'onProcessRowUpdateError' > ,
1823) => {
1924 const { processRowUpdate, onProcessRowUpdateError } = props ;
25+ const { setRowIndex : setRowIndexPlain } = useGridRowsOverridableMethodsCommunity ( apiRef ) ;
26+
27+ const flatTree = useGridSelector ( apiRef , gridRowMaximumTreeDepthSelector ) === 1 ;
2028
2129 const setRowIndex = React . useCallback (
2230 async ( sourceRowId : GridRowId , targetOriginalIndex : number ) => {
@@ -66,6 +74,6 @@ export const useGridRowsOverridableMethods = (
6674 ) ;
6775
6876 return {
69- setRowIndex,
77+ setRowIndex : flatTree ? setRowIndexPlain : setRowIndex ,
7078 } ;
7179} ;
0 commit comments