From c1d16ce7e2b0b6cd7ded14e2b0adf698d016c789 Mon Sep 17 00:00:00 2001 From: Andrew Cherniavskii Date: Mon, 5 Feb 2024 13:45:45 +0100 Subject: [PATCH] [DataGridPremium] Fix error after closing print export (#11889) --- .../src/hooks/features/export/useGridPrintExport.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/grid/x-data-grid/src/hooks/features/export/useGridPrintExport.tsx b/packages/grid/x-data-grid/src/hooks/features/export/useGridPrintExport.tsx index b143d906338b3..83326facecfb9 100644 --- a/packages/grid/x-data-grid/src/hooks/features/export/useGridPrintExport.tsx +++ b/packages/grid/x-data-grid/src/hooks/features/export/useGridPrintExport.tsx @@ -24,6 +24,7 @@ import { } from '../../../components/toolbar/GridToolbarExport'; import { getTotalHeaderHeight } from '../columns/gridColumnsUtils'; import { GRID_CHECKBOX_SELECTION_COL_DEF } from '../../../colDef/gridCheckboxSelectionColDef'; +import { gridDataRowIdsSelector, gridRowsLookupSelector } from '../rows/gridRowsSelector'; function raf() { return new Promise((resolve) => { @@ -303,7 +304,8 @@ export const useGridPrintExport = ( previousGridState.current = apiRef.current.exportState(); // It appends that the visibility model is not exported, especially if columnVisibility is not controlled previousColumnVisibility.current = gridColumnVisibilityModelSelector(apiRef); - previousRows.current = apiRef.current.getSortedRows(); + const gridRowsLookup = gridRowsLookupSelector(apiRef); + previousRows.current = gridDataRowIdsSelector(apiRef).map((rowId) => gridRowsLookup[rowId]); if (props.pagination) { const visibleRowCount = gridExpandedRowCountSelector(apiRef);