From 89215a1d476d3a9700bd17ac20ba55be48719c44 Mon Sep 17 00:00:00 2001 From: Bilal Shafi Date: Mon, 30 Dec 2024 19:58:59 +0500 Subject: [PATCH] [DataGrid] Fix select all checkbox state reset with server side data (#16034) --- .../src/components/columnSelection/GridHeaderCheckbox.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/x-data-grid/src/components/columnSelection/GridHeaderCheckbox.tsx b/packages/x-data-grid/src/components/columnSelection/GridHeaderCheckbox.tsx index 700d9fb6bf38a..7044fa5e901c3 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(() => {