diff --git a/packages/x-data-grid/src/components/columnSelection/GridHeaderCheckbox.tsx b/packages/x-data-grid/src/components/columnSelection/GridHeaderCheckbox.tsx index 421aad304ff68..2c9314197f5a9 100644 --- a/packages/x-data-grid/src/components/columnSelection/GridHeaderCheckbox.tsx +++ b/packages/x-data-grid/src/components/columnSelection/GridHeaderCheckbox.tsx @@ -50,6 +50,9 @@ const GridHeaderCheckbox = forwardRef } return selection.filter((id) => { + if (rootProps.keepNonExistentRowsSelected) { + return true; + } // The row might have been deleted if (!apiRef.current.getRow(id)) { return false; @@ -57,7 +60,7 @@ const GridHeaderCheckbox = forwardRef return rootProps.isRowSelectable!(apiRef.current.getRowParams(id)); }); - }, [apiRef, rootProps.isRowSelectable, selection]); + }, [apiRef, rootProps.isRowSelectable, selection, rootProps.keepNonExistentRowsSelected]); // All the rows that could be selected / unselected by toggling this checkbox const selectionCandidates = React.useMemo(() => {