diff --git a/packages/x-data-grid/src/hooks/features/rowSelection/useGridRowSelection.ts b/packages/x-data-grid/src/hooks/features/rowSelection/useGridRowSelection.ts index c197b147205a5..7fc8dd13d2ccf 100644 --- a/packages/x-data-grid/src/hooks/features/rowSelection/useGridRowSelection.ts +++ b/packages/x-data-grid/src/hooks/features/rowSelection/useGridRowSelection.ts @@ -339,8 +339,8 @@ export const useGridRowSelection = ( } const currentLookup = selectedIdsLookupSelector(apiRef); if ( - newSelection.length === Object.keys(currentLookup).length && - newSelection.every((id) => currentLookup[id] === id) + newSelection.size === Object.keys(currentLookup).length && + Array.from(newSelection).every((id) => currentLookup[id] === id) ) { return; } @@ -504,11 +504,10 @@ export const useGridRowSelection = ( // Example: A parent whose de-selected children are filtered out should now be selected const shouldReapplyPropagation = isNestedData && - !sortModelUpdated && props.rowSelectionPropagation?.parents && Object.keys(selectionLookup).length > 0; - if (hasChanged || shouldReapplyPropagation) { + if (hasChanged || (shouldReapplyPropagation && !sortModelUpdated)) { const newSelection = Object.values(selectionLookup); if (shouldReapplyPropagation) { apiRef.current.selectRows(newSelection, true, true);