@mui/x-data-grid 8.8.0 → 8.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (196) hide show
  1. package/CHANGELOG.md +225 -24
  2. package/DataGrid/DataGrid.js +5 -0
  3. package/DataGrid/index.d.ts +0 -1
  4. package/DataGrid/useDataGridComponent.js +10 -0
  5. package/colDef/gridCheckboxSelectionColDef.js +1 -0
  6. package/components/GridDetailPanels.d.ts +2 -2
  7. package/components/GridPinnedRows.d.ts +2 -2
  8. package/components/GridRow.js +5 -0
  9. package/components/GridScrollArea.js +1 -1
  10. package/components/cell/GridCell.js +7 -5
  11. package/components/cell/GridEditSingleSelectCell.js +1 -1
  12. package/components/columnsManagement/GridColumnsManagement.d.ts +6 -0
  13. package/components/columnsManagement/GridColumnsManagement.js +17 -5
  14. package/components/containers/GridRootStyles.d.ts +1 -1
  15. package/components/containers/GridRootStyles.js +39 -0
  16. package/components/toolbarV8/Toolbar.d.ts +1 -1
  17. package/components/virtualization/GridVirtualScroller.js +5 -5
  18. package/constants/dataGridPropsDefaultValues.js +1 -0
  19. package/constants/gridClasses.d.ts +12 -0
  20. package/constants/gridClasses.js +3 -1
  21. package/esm/DataGrid/DataGrid.js +5 -0
  22. package/esm/DataGrid/index.d.ts +0 -1
  23. package/esm/DataGrid/useDataGridComponent.js +10 -0
  24. package/esm/colDef/gridCheckboxSelectionColDef.js +1 -0
  25. package/esm/components/GridDetailPanels.d.ts +2 -2
  26. package/esm/components/GridPinnedRows.d.ts +2 -2
  27. package/esm/components/GridRow.js +5 -0
  28. package/esm/components/GridScrollArea.js +1 -1
  29. package/esm/components/cell/GridCell.js +7 -5
  30. package/esm/components/cell/GridEditSingleSelectCell.js +1 -1
  31. package/esm/components/columnsManagement/GridColumnsManagement.d.ts +6 -0
  32. package/esm/components/columnsManagement/GridColumnsManagement.js +17 -5
  33. package/esm/components/containers/GridRootStyles.d.ts +1 -1
  34. package/esm/components/containers/GridRootStyles.js +39 -0
  35. package/esm/components/toolbarV8/Toolbar.d.ts +1 -1
  36. package/esm/components/virtualization/GridVirtualScroller.js +5 -5
  37. package/esm/constants/dataGridPropsDefaultValues.js +1 -0
  38. package/esm/constants/gridClasses.d.ts +12 -0
  39. package/esm/constants/gridClasses.js +3 -1
  40. package/esm/hooks/core/pipeProcessing/gridPipeProcessingApi.d.ts +5 -0
  41. package/esm/hooks/core/pipeProcessing/useGridPipeProcessing.js +20 -5
  42. package/esm/hooks/core/useGridProps.d.ts +2 -2
  43. package/esm/hooks/core/useGridProps.js +3 -1
  44. package/esm/hooks/core/useGridVirtualizer.d.ts +9 -0
  45. package/esm/hooks/core/useGridVirtualizer.js +223 -0
  46. package/esm/hooks/features/columnGrouping/gridColumnGroupsInterfaces.d.ts +4 -1
  47. package/esm/hooks/features/columnGrouping/gridColumnGroupsUtils.js +35 -32
  48. package/esm/hooks/features/columnGrouping/useGridColumnGrouping.js +18 -13
  49. package/esm/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +1 -1
  50. package/esm/hooks/features/columnHeaders/useGridColumnHeaders.js +3 -2
  51. package/esm/hooks/features/columns/gridColumnsInterfaces.d.ts +3 -3
  52. package/esm/hooks/features/columns/gridColumnsSelector.js +6 -2
  53. package/esm/hooks/features/columns/gridColumnsUtils.js +6 -4
  54. package/esm/hooks/features/columns/useGridColumnSpanning.js +5 -90
  55. package/esm/hooks/features/columns/useGridColumns.js +8 -10
  56. package/esm/hooks/features/dimensions/useGridDimensions.js +18 -188
  57. package/esm/hooks/features/export/utils.js +1 -1
  58. package/esm/hooks/features/filter/useGridFilter.js +3 -3
  59. package/esm/hooks/features/keyboardNavigation/useGridKeyboardNavigation.d.ts +1 -1
  60. package/esm/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +6 -10
  61. package/esm/hooks/features/keyboardNavigation/utils.d.ts +3 -3
  62. package/esm/hooks/features/keyboardNavigation/utils.js +5 -5
  63. package/esm/hooks/features/listView/gridListViewSelectors.d.ts +8 -1
  64. package/esm/hooks/features/listView/gridListViewSelectors.js +7 -0
  65. package/esm/hooks/features/pivoting/gridPivotingInterfaces.d.ts +0 -1
  66. package/esm/hooks/features/pivoting/gridPivotingSelectors.d.ts +1 -4
  67. package/esm/hooks/features/pivoting/gridPivotingSelectors.js +1 -2
  68. package/esm/hooks/features/rowSelection/useGridRowSelection.js +5 -4
  69. package/esm/hooks/features/rows/gridRowsMetaInterfaces.d.ts +2 -8
  70. package/esm/hooks/features/rows/gridRowsMetaState.d.ts +2 -18
  71. package/esm/hooks/features/rows/gridRowsUtils.d.ts +1 -1
  72. package/esm/hooks/features/rows/gridRowsUtils.js +5 -2
  73. package/esm/hooks/features/rows/useGridRowAriaAttributes.js +3 -1
  74. package/esm/hooks/features/rows/useGridRowSpanning.d.ts +2 -12
  75. package/esm/hooks/features/rows/useGridRowSpanning.js +54 -85
  76. package/esm/hooks/features/rows/useGridRows.js +4 -3
  77. package/esm/hooks/features/rows/useGridRowsMeta.d.ts +1 -1
  78. package/esm/hooks/features/rows/useGridRowsMeta.js +17 -187
  79. package/esm/hooks/features/scroll/useGridScroll.d.ts +1 -1
  80. package/esm/hooks/features/scroll/useGridScroll.js +2 -3
  81. package/esm/hooks/features/virtualization/gridVirtualizationSelectors.d.ts +1 -1
  82. package/esm/hooks/features/virtualization/index.d.ts +1 -0
  83. package/esm/hooks/features/virtualization/index.js +1 -0
  84. package/esm/hooks/features/virtualization/useGridVirtualization.d.ts +5 -16
  85. package/esm/hooks/features/virtualization/useGridVirtualization.js +41 -22
  86. package/esm/hooks/utils/index.d.ts +2 -1
  87. package/esm/hooks/utils/index.js +2 -1
  88. package/esm/hooks/utils/useFirstRender.d.ts +1 -1
  89. package/esm/hooks/utils/useFirstRender.js +1 -8
  90. package/esm/hooks/utils/useGridInitializeState.d.ts +1 -1
  91. package/esm/hooks/utils/useGridInitializeState.js +6 -1
  92. package/esm/hooks/utils/useRunOncePerLoop.d.ts +1 -0
  93. package/esm/hooks/utils/useRunOncePerLoop.js +26 -0
  94. package/esm/index.js +1 -1
  95. package/esm/internals/index.d.ts +1 -1
  96. package/esm/internals/index.js +1 -1
  97. package/esm/internals/utils/getPinnedCellOffset.js +5 -0
  98. package/esm/locales/frFR.js +18 -21
  99. package/esm/locales/heIL.js +12 -12
  100. package/esm/locales/plPL.js +22 -24
  101. package/esm/models/api/gridApiCommon.d.ts +4 -1
  102. package/esm/models/api/gridColumnSpanning.d.ts +5 -11
  103. package/esm/models/api/gridRowApi.d.ts +5 -0
  104. package/esm/models/events/gridEventLookup.d.ts +2 -1
  105. package/esm/models/gridApiCaches.d.ts +8 -2
  106. package/esm/models/gridStateCommunity.d.ts +2 -2
  107. package/esm/models/props/DataGridProps.d.ts +5 -0
  108. package/esm/utils/roundToDecimalPlaces.d.ts +1 -1
  109. package/esm/utils/roundToDecimalPlaces.js +1 -3
  110. package/hooks/core/pipeProcessing/gridPipeProcessingApi.d.ts +5 -0
  111. package/hooks/core/pipeProcessing/useGridPipeProcessing.js +20 -5
  112. package/hooks/core/useGridProps.d.ts +2 -2
  113. package/hooks/core/useGridProps.js +3 -1
  114. package/hooks/core/useGridVirtualizer.d.ts +9 -0
  115. package/hooks/core/useGridVirtualizer.js +231 -0
  116. package/hooks/features/columnGrouping/gridColumnGroupsInterfaces.d.ts +4 -1
  117. package/hooks/features/columnGrouping/gridColumnGroupsUtils.js +35 -32
  118. package/hooks/features/columnGrouping/useGridColumnGrouping.js +18 -13
  119. package/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +1 -1
  120. package/hooks/features/columnHeaders/useGridColumnHeaders.js +4 -3
  121. package/hooks/features/columns/gridColumnsInterfaces.d.ts +3 -3
  122. package/hooks/features/columns/gridColumnsSelector.js +6 -2
  123. package/hooks/features/columns/gridColumnsUtils.js +6 -4
  124. package/hooks/features/columns/useGridColumnSpanning.js +5 -91
  125. package/hooks/features/columns/useGridColumns.js +8 -10
  126. package/hooks/features/dimensions/useGridDimensions.js +18 -188
  127. package/hooks/features/export/utils.js +1 -1
  128. package/hooks/features/filter/useGridFilter.js +3 -3
  129. package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.d.ts +1 -1
  130. package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +6 -10
  131. package/hooks/features/keyboardNavigation/utils.d.ts +3 -3
  132. package/hooks/features/keyboardNavigation/utils.js +5 -5
  133. package/hooks/features/listView/gridListViewSelectors.d.ts +8 -1
  134. package/hooks/features/listView/gridListViewSelectors.js +8 -1
  135. package/hooks/features/pivoting/gridPivotingInterfaces.d.ts +0 -1
  136. package/hooks/features/pivoting/gridPivotingSelectors.d.ts +1 -4
  137. package/hooks/features/pivoting/gridPivotingSelectors.js +2 -3
  138. package/hooks/features/rowSelection/useGridRowSelection.js +5 -4
  139. package/hooks/features/rows/gridRowsMetaInterfaces.d.ts +2 -8
  140. package/hooks/features/rows/gridRowsMetaState.d.ts +2 -18
  141. package/hooks/features/rows/gridRowsUtils.d.ts +1 -1
  142. package/hooks/features/rows/gridRowsUtils.js +5 -2
  143. package/hooks/features/rows/useGridRowAriaAttributes.js +3 -1
  144. package/hooks/features/rows/useGridRowSpanning.d.ts +2 -12
  145. package/hooks/features/rows/useGridRowSpanning.js +54 -85
  146. package/hooks/features/rows/useGridRows.js +4 -3
  147. package/hooks/features/rows/useGridRowsMeta.d.ts +1 -1
  148. package/hooks/features/rows/useGridRowsMeta.js +15 -186
  149. package/hooks/features/scroll/useGridScroll.d.ts +1 -1
  150. package/hooks/features/scroll/useGridScroll.js +2 -3
  151. package/hooks/features/virtualization/gridVirtualizationSelectors.d.ts +1 -1
  152. package/hooks/features/virtualization/index.d.ts +1 -0
  153. package/hooks/features/virtualization/index.js +12 -0
  154. package/hooks/features/virtualization/useGridVirtualization.d.ts +5 -16
  155. package/hooks/features/virtualization/useGridVirtualization.js +42 -24
  156. package/hooks/utils/index.d.ts +2 -1
  157. package/hooks/utils/index.js +16 -4
  158. package/hooks/utils/useFirstRender.d.ts +1 -1
  159. package/hooks/utils/useFirstRender.js +11 -11
  160. package/hooks/utils/useGridInitializeState.d.ts +1 -1
  161. package/hooks/utils/useGridInitializeState.js +6 -1
  162. package/hooks/utils/useRunOncePerLoop.d.ts +1 -0
  163. package/hooks/utils/useRunOncePerLoop.js +33 -0
  164. package/index.js +1 -1
  165. package/internals/index.d.ts +1 -1
  166. package/internals/index.js +4 -11
  167. package/internals/utils/getPinnedCellOffset.js +5 -0
  168. package/locales/frFR.js +18 -21
  169. package/locales/heIL.js +12 -12
  170. package/locales/plPL.js +22 -24
  171. package/models/api/gridApiCommon.d.ts +4 -1
  172. package/models/api/gridColumnSpanning.d.ts +5 -11
  173. package/models/api/gridRowApi.d.ts +5 -0
  174. package/models/events/gridEventLookup.d.ts +2 -1
  175. package/models/gridApiCaches.d.ts +8 -2
  176. package/models/gridStateCommunity.d.ts +2 -2
  177. package/models/props/DataGridProps.d.ts +5 -0
  178. package/package.json +5 -5
  179. package/utils/roundToDecimalPlaces.d.ts +1 -1
  180. package/utils/roundToDecimalPlaces.js +7 -4
  181. package/esm/hooks/features/rows/gridRowSpanningSelectors.d.ts +0 -10
  182. package/esm/hooks/features/rows/gridRowSpanningSelectors.js +0 -5
  183. package/esm/hooks/features/virtualization/useGridVirtualScroller.d.ts +0 -56
  184. package/esm/hooks/features/virtualization/useGridVirtualScroller.js +0 -846
  185. package/esm/hooks/utils/useRunOnce.d.ts +0 -5
  186. package/esm/hooks/utils/useRunOnce.js +0 -18
  187. package/esm/utils/platform.d.ts +0 -1
  188. package/esm/utils/platform.js +0 -2
  189. package/hooks/features/rows/gridRowSpanningSelectors.d.ts +0 -10
  190. package/hooks/features/rows/gridRowSpanningSelectors.js +0 -11
  191. package/hooks/features/virtualization/useGridVirtualScroller.d.ts +0 -56
  192. package/hooks/features/virtualization/useGridVirtualScroller.js +0 -857
  193. package/hooks/utils/useRunOnce.d.ts +0 -5
  194. package/hooks/utils/useRunOnce.js +0 -27
  195. package/utils/platform.d.ts +0 -1
  196. package/utils/platform.js +0 -8
@@ -1,4 +1,3 @@
1
- import * as React from 'react';
2
1
  import { useGridApiMethod } from "../../utils/useGridApiMethod.js";
3
2
  import { useGridEvent } from "../../utils/useGridEvent.js";
4
3
  /**
@@ -6,36 +5,10 @@ import { useGridEvent } from "../../utils/useGridEvent.js";
6
5
  * @requires useGridParamsApi (method)
7
6
  */
8
7
  export const useGridColumnSpanning = apiRef => {
9
- const lookup = React.useRef({});
10
- const getCellColSpanInfo = (rowId, columnIndex) => {
11
- return lookup.current[rowId]?.[columnIndex];
12
- };
13
- const resetColSpan = () => {
14
- lookup.current = {};
15
- };
16
-
17
- // Calculate `colSpan` for each cell in the row
18
- const calculateColSpan = React.useCallback(({
19
- rowId,
20
- minFirstColumn,
21
- maxLastColumn,
22
- columns
23
- }) => {
24
- for (let i = minFirstColumn; i < maxLastColumn; i += 1) {
25
- const cellProps = calculateCellColSpan({
26
- apiRef,
27
- lookup: lookup.current,
28
- columnIndex: i,
29
- rowId,
30
- minFirstColumnIndex: minFirstColumn,
31
- maxLastColumnIndex: maxLastColumn,
32
- columns
33
- });
34
- if (cellProps.colSpan > 1) {
35
- i += cellProps.colSpan - 1;
36
- }
37
- }
38
- }, [apiRef]);
8
+ const virtualizer = apiRef.current.virtualizer;
9
+ const resetColSpan = virtualizer.api.resetColSpan;
10
+ const getCellColSpanInfo = virtualizer.api.getCellColSpanInfo;
11
+ const calculateColSpan = virtualizer.api.calculateColSpan;
39
12
  const columnSpanningPublicApi = {
40
13
  unstable_getCellColSpanInfo: getCellColSpanInfo
41
14
  };
@@ -46,62 +19,4 @@ export const useGridColumnSpanning = apiRef => {
46
19
  useGridApiMethod(apiRef, columnSpanningPublicApi, 'public');
47
20
  useGridApiMethod(apiRef, columnSpanningPrivateApi, 'private');
48
21
  useGridEvent(apiRef, 'columnOrderChange', resetColSpan);
49
- };
50
- function calculateCellColSpan(params) {
51
- const {
52
- apiRef,
53
- lookup,
54
- columnIndex,
55
- rowId,
56
- minFirstColumnIndex,
57
- maxLastColumnIndex,
58
- columns
59
- } = params;
60
- const columnsLength = columns.length;
61
- const column = columns[columnIndex];
62
- const row = apiRef.current.getRow(rowId);
63
- const value = apiRef.current.getRowValue(row, column);
64
- const colSpan = typeof column.colSpan === 'function' ? column.colSpan(value, row, column, apiRef) : column.colSpan;
65
- if (!colSpan || colSpan === 1) {
66
- setCellColSpanInfo(lookup, rowId, columnIndex, {
67
- spannedByColSpan: false,
68
- cellProps: {
69
- colSpan: 1,
70
- width: column.computedWidth
71
- }
72
- });
73
- return {
74
- colSpan: 1
75
- };
76
- }
77
- let width = column.computedWidth;
78
- for (let j = 1; j < colSpan; j += 1) {
79
- const nextColumnIndex = columnIndex + j;
80
- // Cells should be spanned only within their column section (left-pinned, right-pinned and unpinned).
81
- if (nextColumnIndex >= minFirstColumnIndex && nextColumnIndex < maxLastColumnIndex) {
82
- const nextColumn = columns[nextColumnIndex];
83
- width += nextColumn.computedWidth;
84
- setCellColSpanInfo(lookup, rowId, columnIndex + j, {
85
- spannedByColSpan: true,
86
- rightVisibleCellIndex: Math.min(columnIndex + colSpan, columnsLength - 1),
87
- leftVisibleCellIndex: columnIndex
88
- });
89
- }
90
- setCellColSpanInfo(lookup, rowId, columnIndex, {
91
- spannedByColSpan: false,
92
- cellProps: {
93
- colSpan,
94
- width
95
- }
96
- });
97
- }
98
- return {
99
- colSpan
100
- };
101
- }
102
- function setCellColSpanInfo(lookup, rowId, columnIndex, cellColSpanInfo) {
103
- if (!lookup[rowId]) {
104
- lookup[rowId] = {};
105
- }
106
- lookup[rowId][columnIndex] = cellColSpanInfo;
107
- }
22
+ };
@@ -14,6 +14,9 @@ import { GridPreferencePanelsValue } from "../preferencesPanel/index.js";
14
14
  import { gridPivotActiveSelector } from "../pivoting/index.js";
15
15
  import { jsx as _jsx } from "react/jsx-runtime";
16
16
  export const columnsStateInitializer = (state, props, apiRef) => {
17
+ apiRef.current.caches.columns = {
18
+ lastColumnsProp: props.columns
19
+ };
17
20
  const columnsState = createColumnsState({
18
21
  apiRef,
19
22
  columnsToUpsert: props.columns,
@@ -36,7 +39,6 @@ export const columnsStateInitializer = (state, props, apiRef) => {
36
39
  */
37
40
  export function useGridColumns(apiRef, props) {
38
41
  const logger = useGridLogger(apiRef, 'useGridColumns');
39
- const previousColumnsProp = React.useRef(props.columns);
40
42
  apiRef.current.registerControlState({
41
43
  stateId: 'visibleColumns',
42
44
  propModel: props.columnVisibilityModel,
@@ -299,27 +301,23 @@ export function useGridColumns(apiRef, props) {
299
301
  */
300
302
  // The effect do not track any value defined synchronously during the 1st render by hooks called after `useGridColumns`
301
303
  // As a consequence, the state generated by the 1st run of this useEffect will always be equal to the initialization one
302
- const isFirstRender = React.useRef(true);
303
304
  React.useEffect(() => {
304
- if (isFirstRender.current) {
305
- isFirstRender.current = false;
305
+ if (apiRef.current.caches.columns.lastColumnsProp === props.columns) {
306
306
  return;
307
307
  }
308
+ apiRef.current.caches.columns.lastColumnsProp = props.columns;
308
309
  logger.info(`GridColumns have changed, new length ${props.columns.length}`);
309
- if (previousColumnsProp.current === props.columns) {
310
- return;
311
- }
312
310
  const columnsState = createColumnsState({
313
311
  apiRef,
314
312
  initialState: undefined,
315
313
  // If the user provides a model, we don't want to set it in the state here because it has it's dedicated `useEffect` which calls `setColumnVisibilityModel`
316
314
  columnsToUpsert: props.columns,
317
315
  keepOnlyColumnsToUpsert: true,
318
- updateInitialVisibilityModel: true
316
+ updateInitialVisibilityModel: true,
317
+ columnVisibilityModel: props.columnVisibilityModel
319
318
  });
320
- previousColumnsProp.current = props.columns;
321
319
  setGridColumnsState(columnsState);
322
- }, [logger, apiRef, setGridColumnsState, props.columns]);
320
+ }, [logger, apiRef, setGridColumnsState, props.columns, props.columnVisibilityModel]);
323
321
  React.useEffect(() => {
324
322
  if (props.columnVisibilityModel !== undefined) {
325
323
  apiRef.current.setColumnVisibilityModel(props.columnVisibilityModel);
@@ -2,11 +2,8 @@
2
2
 
3
3
  import _extends from "@babel/runtime/helpers/esm/extends";
4
4
  import * as React from 'react';
5
- import useEventCallback from '@mui/utils/useEventCallback';
6
- import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
7
- import ownerDocument from '@mui/utils/ownerDocument';
8
- import { throttle } from '@mui/x-internals/throttle';
9
- import { isDeepEqual } from '@mui/x-internals/isDeepEqual';
5
+ import { useStoreEffect } from '@mui/x-internals/store';
6
+ import { Dimensions } from '@mui/x-virtualizer';
10
7
  import { useGridEventPriority } from "../../utils/useGridEvent.js";
11
8
  import { useGridApiMethod } from "../../utils/useGridApiMethod.js";
12
9
  import { createSelector } from "../../../utils/createSelector.js";
@@ -14,10 +11,6 @@ import { useGridLogger } from "../../utils/useGridLogger.js";
14
11
  import { gridColumnPositionsSelector, gridVisibleColumnDefinitionsSelector, gridVisiblePinnedColumnDefinitionsSelector } from "../columns/index.js";
15
12
  import { gridDimensionsSelector } from "./gridDimensionsSelectors.js";
16
13
  import { gridDensityFactorSelector } from "../density/index.js";
17
- import { gridRenderContextSelector } from "../virtualization/index.js";
18
- import { useGridSelector } from "../../utils/index.js";
19
- import { getVisibleRows } from "../../utils/useGridVisibleRows.js";
20
- import { gridRowsMetaSelector } from "../rows/gridRowsMetaSelector.js";
21
14
  import { getValidRowHeight, rowHeightWarning } from "../rows/gridRowsUtils.js";
22
15
  import { getTotalHeaderHeight } from "../columns/gridColumnsUtils.js";
23
16
  import { DATA_GRID_PROPS_DEFAULT_VALUES } from "../../../constants/dataGridPropsDefaultValues.js";
@@ -66,148 +59,10 @@ const columnsTotalWidthSelector = createSelector(gridVisibleColumnDefinitionsSel
66
59
  export function useGridDimensions(apiRef, props) {
67
60
  const logger = useGridLogger(apiRef, 'useResizeContainer');
68
61
  const errorShown = React.useRef(false);
69
- const rootDimensionsRef = React.useRef(EMPTY_SIZE);
70
- const pinnedColumns = useGridSelector(apiRef, gridVisiblePinnedColumnDefinitionsSelector);
71
- const densityFactor = useGridSelector(apiRef, gridDensityFactorSelector);
72
- const columnsTotalWidth = useGridSelector(apiRef, columnsTotalWidthSelector);
73
- const isFirstSizing = React.useRef(true);
74
- const {
75
- rowHeight,
76
- headerHeight,
77
- groupHeaderHeight,
78
- headerFilterHeight,
79
- headersTotalHeight,
80
- leftPinnedWidth,
81
- rightPinnedWidth
82
- } = getStaticDimensions(props, apiRef, densityFactor, pinnedColumns);
62
+ const virtualizer = apiRef.current.virtualizer;
63
+ const updateDimensions = virtualizer.api.updateDimensions;
64
+ const getViewportPageSize = virtualizer.api.getViewportPageSize;
83
65
  const getRootDimensions = React.useCallback(() => gridDimensionsSelector(apiRef), [apiRef]);
84
- const setDimensions = React.useCallback(dimensions => {
85
- apiRef.current.setState(state => _extends({}, state, {
86
- dimensions
87
- }));
88
- if (apiRef.current.rootElementRef.current) {
89
- setCSSVariables(apiRef.current.rootElementRef.current, gridDimensionsSelector(apiRef));
90
- }
91
- }, [apiRef]);
92
- const getViewportPageSize = React.useCallback(() => {
93
- const dimensions = gridDimensionsSelector(apiRef);
94
- if (!dimensions.isReady) {
95
- return 0;
96
- }
97
- const currentPage = getVisibleRows(apiRef);
98
-
99
- // TODO: Use a combination of scrollTop, dimensions.viewportInnerSize.height and rowsMeta.possitions
100
- // to find out the maximum number of rows that can fit in the visible part of the grid
101
- if (props.getRowHeight) {
102
- const renderContext = gridRenderContextSelector(apiRef);
103
- const viewportPageSize = renderContext.lastRowIndex - renderContext.firstRowIndex;
104
- return Math.min(viewportPageSize - 1, currentPage.rows.length);
105
- }
106
- const maximumPageSizeWithoutScrollBar = Math.floor(dimensions.viewportInnerSize.height / rowHeight);
107
- return Math.min(maximumPageSizeWithoutScrollBar, currentPage.rows.length);
108
- }, [apiRef, props.getRowHeight, rowHeight]);
109
- const updateDimensions = React.useCallback(() => {
110
- if (isFirstSizing.current) {
111
- return;
112
- }
113
- // All the floating point dimensions should be rounded to .1 decimal places to avoid subpixel rendering issues
114
- // https://github.com/mui/mui-x/issues/9550#issuecomment-1619020477
115
- // https://github.com/mui/mui-x/issues/15721
116
- const scrollbarSize = measureScrollbarSize(apiRef.current.mainElementRef.current, props.scrollbarSize);
117
- const rowsMeta = gridRowsMetaSelector(apiRef);
118
- const topContainerHeight = headersTotalHeight + rowsMeta.pinnedTopRowsTotalHeight;
119
- const bottomContainerHeight = rowsMeta.pinnedBottomRowsTotalHeight;
120
- const contentSize = {
121
- width: columnsTotalWidth,
122
- height: roundToDecimalPlaces(rowsMeta.currentPageTotalHeight, 1)
123
- };
124
- let viewportOuterSize;
125
- let viewportInnerSize;
126
- let hasScrollX = false;
127
- let hasScrollY = false;
128
- if (props.autoHeight) {
129
- hasScrollY = false;
130
- hasScrollX = Math.round(columnsTotalWidth) > Math.round(rootDimensionsRef.current.width);
131
- viewportOuterSize = {
132
- width: rootDimensionsRef.current.width,
133
- height: topContainerHeight + bottomContainerHeight + contentSize.height
134
- };
135
- viewportInnerSize = {
136
- width: Math.max(0, viewportOuterSize.width - (hasScrollY ? scrollbarSize : 0)),
137
- height: Math.max(0, viewportOuterSize.height - (hasScrollX ? scrollbarSize : 0))
138
- };
139
- } else {
140
- viewportOuterSize = {
141
- width: rootDimensionsRef.current.width,
142
- height: rootDimensionsRef.current.height
143
- };
144
- viewportInnerSize = {
145
- width: Math.max(0, viewportOuterSize.width),
146
- height: Math.max(0, viewportOuterSize.height - topContainerHeight - bottomContainerHeight)
147
- };
148
- const content = contentSize;
149
- const container = viewportInnerSize;
150
- const hasScrollXIfNoYScrollBar = content.width > container.width;
151
- const hasScrollYIfNoXScrollBar = content.height > container.height;
152
- if (hasScrollXIfNoYScrollBar || hasScrollYIfNoXScrollBar) {
153
- hasScrollY = hasScrollYIfNoXScrollBar;
154
- hasScrollX = content.width + (hasScrollY ? scrollbarSize : 0) > container.width;
155
-
156
- // We recalculate the scroll y to consider the size of the x scrollbar.
157
- if (hasScrollX) {
158
- hasScrollY = content.height + scrollbarSize > container.height;
159
- }
160
- }
161
- if (hasScrollY) {
162
- viewportInnerSize.width -= scrollbarSize;
163
- }
164
- if (hasScrollX) {
165
- viewportInnerSize.height -= scrollbarSize;
166
- }
167
- }
168
- const rowWidth = Math.max(viewportOuterSize.width, columnsTotalWidth + (hasScrollY ? scrollbarSize : 0));
169
- const minimumSize = {
170
- width: columnsTotalWidth,
171
- height: topContainerHeight + contentSize.height + bottomContainerHeight
172
- };
173
- const newDimensions = {
174
- isReady: true,
175
- root: rootDimensionsRef.current,
176
- viewportOuterSize,
177
- viewportInnerSize,
178
- contentSize,
179
- minimumSize,
180
- hasScrollX,
181
- hasScrollY,
182
- scrollbarSize,
183
- headerHeight,
184
- groupHeaderHeight,
185
- headerFilterHeight,
186
- rowWidth,
187
- rowHeight,
188
- columnsTotalWidth,
189
- leftPinnedWidth,
190
- rightPinnedWidth,
191
- headersTotalHeight,
192
- topContainerHeight,
193
- bottomContainerHeight
194
- };
195
- const prevDimensions = apiRef.current.state.dimensions;
196
- if (isDeepEqual(prevDimensions, newDimensions)) {
197
- return;
198
- }
199
- setDimensions(newDimensions);
200
- if (!areElementSizesEqual(newDimensions.viewportInnerSize, prevDimensions.viewportInnerSize)) {
201
- apiRef.current.publishEvent('viewportInnerSizeChange', newDimensions.viewportInnerSize);
202
- }
203
- apiRef.current.updateRenderContext?.();
204
- }, [apiRef, setDimensions, props.scrollbarSize, props.autoHeight, rowHeight, headerHeight, groupHeaderHeight, headerFilterHeight, columnsTotalWidth, headersTotalHeight, leftPinnedWidth, rightPinnedWidth]);
205
- const updateDimensionCallback = useEventCallback(updateDimensions);
206
- const debouncedUpdateDimensions = React.useMemo(() => props.resizeThrottleMs > 0 ? throttle(() => {
207
- updateDimensionCallback();
208
- apiRef.current.publishEvent('debouncedResize', rootDimensionsRef.current);
209
- }, props.resizeThrottleMs) : undefined, [apiRef, props.resizeThrottleMs, updateDimensionCallback]);
210
- React.useEffect(() => debouncedUpdateDimensions?.clear, [debouncedUpdateDimensions]);
211
66
  const apiPublic = {
212
67
  getRootDimensions
213
68
  };
@@ -215,14 +70,12 @@ export function useGridDimensions(apiRef, props) {
215
70
  updateDimensions,
216
71
  getViewportPageSize
217
72
  };
218
- useEnhancedEffect(updateDimensions, [updateDimensions]);
219
73
  useGridApiMethod(apiRef, apiPublic, 'public');
220
74
  useGridApiMethod(apiRef, apiPrivate, 'private');
221
- const handleRootMount = React.useCallback(root => {
75
+ const handleRootMount = root => {
222
76
  setCSSVariables(root, gridDimensionsSelector(apiRef));
223
- }, [apiRef]);
224
- const handleResize = React.useCallback(size => {
225
- rootDimensionsRef.current = size;
77
+ };
78
+ const handleResize = size => {
226
79
  if (size.height === 0 && !errorShown.current && !props.autoHeight && !isJSDOM) {
227
80
  logger.error(['The parent DOM element of the Data Grid has an empty height.', 'Please make sure that this element has an intrinsic height.', 'The grid displays with a height of 0px.', '', 'More details: https://mui.com/r/x-data-grid-no-dimensions.'].join('\n'));
228
81
  errorShown.current = true;
@@ -231,17 +84,19 @@ export function useGridDimensions(apiRef, props) {
231
84
  logger.error(['The parent DOM element of the Data Grid has an empty width.', 'Please make sure that this element has an intrinsic width.', 'The grid displays with a width of 0px.', '', 'More details: https://mui.com/r/x-data-grid-no-dimensions.'].join('\n'));
232
85
  errorShown.current = true;
233
86
  }
234
- if (isFirstSizing.current || !debouncedUpdateDimensions) {
235
- // We want to initialize the grid dimensions as soon as possible to avoid flickering
236
- isFirstSizing.current = false;
237
- updateDimensions();
238
- return;
239
- }
240
- debouncedUpdateDimensions();
241
- }, [updateDimensions, props.autoHeight, debouncedUpdateDimensions, logger]);
87
+ };
242
88
  useGridEventPriority(apiRef, 'rootMount', handleRootMount);
243
89
  useGridEventPriority(apiRef, 'resize', handleResize);
244
90
  useGridEventPriority(apiRef, 'debouncedResize', props.onResize);
91
+ useStoreEffect(virtualizer.store, Dimensions.selectors.dimensions, (previous, next) => {
92
+ if (apiRef.current.rootElementRef.current) {
93
+ setCSSVariables(apiRef.current.rootElementRef.current, next);
94
+ }
95
+ if (!areElementSizesEqual(next.viewportInnerSize, previous.viewportInnerSize)) {
96
+ apiRef.current.publishEvent('viewportInnerSizeChange', next.viewportInnerSize);
97
+ }
98
+ apiRef.current.publishEvent('debouncedResize', next.root);
99
+ });
245
100
  }
246
101
  function setCSSVariables(root, dimensions) {
247
102
  const set = (k, v) => root.style.setProperty(k, v);
@@ -271,31 +126,6 @@ function getStaticDimensions(props, apiRef, density, pinnedColumnns) {
271
126
  rightPinnedWidth: pinnedColumnns.right.reduce((w, col) => w + col.computedWidth, 0)
272
127
  };
273
128
  }
274
- const scrollbarSizeCache = new WeakMap();
275
- function measureScrollbarSize(element, scrollbarSize) {
276
- if (scrollbarSize !== undefined) {
277
- return scrollbarSize;
278
- }
279
- if (element === null) {
280
- return 0;
281
- }
282
- const cachedSize = scrollbarSizeCache.get(element);
283
- if (cachedSize !== undefined) {
284
- return cachedSize;
285
- }
286
- const doc = ownerDocument(element);
287
- const scrollDiv = doc.createElement('div');
288
- scrollDiv.style.width = '99px';
289
- scrollDiv.style.height = '99px';
290
- scrollDiv.style.position = 'absolute';
291
- scrollDiv.style.overflow = 'scroll';
292
- scrollDiv.className = 'scrollDiv';
293
- element.appendChild(scrollDiv);
294
- const size = scrollDiv.offsetWidth - scrollDiv.clientWidth;
295
- element.removeChild(scrollDiv);
296
- scrollbarSizeCache.set(element, size);
297
- return size;
298
- }
299
129
  function areElementSizesEqual(a, b) {
300
130
  return a.width === b.width && a.height === b.height;
301
131
  }
@@ -17,7 +17,7 @@ export const getColumnsToExport = ({
17
17
  }, []);
18
18
  }
19
19
  const validColumns = options.allColumns ? columns : gridVisibleColumnDefinitionsSelector(apiRef);
20
- return validColumns.filter(column => !column.disableExport);
20
+ return validColumns.filter(column => column.disableExport !== true);
21
21
  };
22
22
  export const defaultGetRowsToExport = ({
23
23
  apiRef
@@ -342,9 +342,9 @@ export const useGridFilter = (apiRef, props) => {
342
342
  useGridEvent(apiRef, 'rowExpansionChange', updateVisibleRowsLookupState);
343
343
  useGridEvent(apiRef, 'columnVisibilityModelChange', () => {
344
344
  const filterModel = gridFilterModelSelector(apiRef);
345
- if (filterModel.quickFilterValues && shouldQuickFilterExcludeHiddenColumns(filterModel)) {
345
+ if (filterModel.quickFilterValues?.length && shouldQuickFilterExcludeHiddenColumns(filterModel)) {
346
346
  // re-apply filters because the quick filter results may have changed
347
- apiRef.current.unstable_applyFilters();
347
+ updateFilteredRows();
348
348
  }
349
349
  });
350
350
 
@@ -352,7 +352,7 @@ export const useGridFilter = (apiRef, props) => {
352
352
  * 1ST RENDER
353
353
  */
354
354
  useFirstRender(() => {
355
- apiRef.current.unstable_applyFilters();
355
+ updateFilteredRows();
356
356
  });
357
357
 
358
358
  /**
@@ -10,4 +10,4 @@ import { DataGridProcessedProps } from "../../../models/props/DataGridProps.js";
10
10
  * @requires useGridScroll (method) - can be after
11
11
  * @requires useGridColumnSpanning (method) - can be after
12
12
  */
13
- export declare const useGridKeyboardNavigation: (apiRef: RefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "pagination" | "paginationMode" | "getRowId" | "signature" | "headerFilters" | "listView">) => void;
13
+ export declare const useGridKeyboardNavigation: (apiRef: RefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "pagination" | "paginationMode" | "getRowId" | "signature" | "headerFilters">) => void;
@@ -16,7 +16,6 @@ import { gridHeaderFilteringEditFieldSelector, gridHeaderFilteringMenuSelector }
16
16
  import { useGridRegisterPipeProcessor } from "../../core/pipeProcessing/index.js";
17
17
  import { isEventTargetInPortal } from "../../../utils/domUtils.js";
18
18
  import { getLeftColumnIndex, getRightColumnIndex, findNonRowSpannedCell } from "./utils.js";
19
- import { gridListColumnSelector } from "../listView/gridListViewSelectors.js";
20
19
  import { createSelectorMemoized } from "../../../utils/createSelector.js";
21
20
  import { gridVisibleRowsSelector } from "../pagination/index.js";
22
21
  import { gridPinnedRowsSelector } from "../rows/gridRowsSelector.js";
@@ -36,7 +35,6 @@ const gridVisibleRowsWithPinnedRowsSelector = createSelectorMemoized(gridVisible
36
35
  export const useGridKeyboardNavigation = (apiRef, props) => {
37
36
  const logger = useGridLogger(apiRef, 'useGridKeyboardNavigation');
38
37
  const isRtl = useRtl();
39
- const listView = props.listView;
40
38
  const getCurrentPageRows = React.useCallback(() => {
41
39
  return gridVisibleRowsWithPinnedRowsSelector(apiRef);
42
40
  }, [apiRef]);
@@ -59,8 +57,8 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
59
57
  colIndex = nextCellColSpanInfo.rightVisibleCellIndex;
60
58
  }
61
59
  }
62
- const field = listView ? gridListColumnSelector(apiRef).field : gridVisibleColumnFieldsSelector(apiRef)[colIndex];
63
- const nonRowSpannedRowId = findNonRowSpannedCell(apiRef, rowId, field, rowSpanScanDirection);
60
+ const field = gridVisibleColumnFieldsSelector(apiRef)[colIndex];
61
+ const nonRowSpannedRowId = findNonRowSpannedCell(apiRef, rowId, colIndex, rowSpanScanDirection);
64
62
  // `scrollToIndexes` requires a rowIndex relative to all visible rows.
65
63
  // Those rows do not include pinned rows, but pinned rows do not need scroll anyway.
66
64
  const rowIndexRelativeToAllRows = visibleSortedRows.findIndex(row => row.id === nonRowSpannedRowId);
@@ -70,7 +68,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
70
68
  rowIndex: rowIndexRelativeToAllRows
71
69
  });
72
70
  apiRef.current.setCellFocus(nonRowSpannedRowId, field);
73
- }, [apiRef, logger, listView]);
71
+ }, [apiRef, logger]);
74
72
  const goToHeader = React.useCallback((colIndex, event) => {
75
73
  logger.debug(`Navigating to header col ${colIndex}`);
76
74
  apiRef.current.scrollToIndexes({
@@ -395,14 +393,12 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
395
393
  return;
396
394
  }
397
395
  const viewportPageSize = apiRef.current.getViewportPageSize();
398
- const getColumnIndexFn = listView ? () => 0 : apiRef.current.getColumnIndex;
399
- const colIndexBefore = params.field ? getColumnIndexFn(params.field) : 0;
396
+ const colIndexBefore = params.field ? apiRef.current.getColumnIndex(params.field) : 0;
400
397
  const rowIndexBefore = currentPageRows.findIndex(row => row.id === params.id);
401
398
  const firstRowIndexInPage = 0;
402
399
  const lastRowIndexInPage = currentPageRows.length - 1;
403
400
  const firstColIndex = 0;
404
- const visibleColumns = listView ? [gridListColumnSelector(apiRef)] : gridVisibleColumnDefinitionsSelector(apiRef);
405
- const lastColIndex = visibleColumns.length - 1;
401
+ const lastColIndex = gridVisibleColumnDefinitionsSelector(apiRef).length - 1;
406
402
  let shouldPreventDefault = true;
407
403
  switch (event.key) {
408
404
  case 'ArrowDown':
@@ -519,7 +515,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
519
515
  if (shouldPreventDefault) {
520
516
  event.preventDefault();
521
517
  }
522
- }, [apiRef, getCurrentPageRows, isRtl, goToCell, getRowIdFromIndex, headerFilteringEnabled, goToHeaderFilter, goToHeader, listView]);
518
+ }, [apiRef, getCurrentPageRows, isRtl, goToCell, getRowIdFromIndex, headerFilteringEnabled, goToHeaderFilter, goToHeader]);
523
519
  const checkIfCanStartEditing = React.useCallback((initialValue, {
524
520
  event
525
521
  }) => {
@@ -1,6 +1,6 @@
1
1
  import { RefObject } from '@mui/x-internals/types';
2
- import { GridColDef, GridRowId } from "../../../models/index.js";
3
- import { GridApiCommunity } from "../../../models/api/gridApiCommunity.js";
2
+ import { GridRowId } from "../../../models/index.js";
3
+ import { GridPrivateApiCommunity } from "../../../models/api/gridApiCommunity.js";
4
4
  export declare const getLeftColumnIndex: ({
5
5
  currentColIndex,
6
6
  firstColIndex,
@@ -23,4 +23,4 @@ export declare const getRightColumnIndex: ({
23
23
  lastColIndex: number;
24
24
  isRtl: boolean;
25
25
  }) => number | null;
26
- export declare function findNonRowSpannedCell(apiRef: RefObject<GridApiCommunity>, rowId: GridRowId, field: GridColDef['field'], rowSpanScanDirection: 'up' | 'down'): GridRowId;
26
+ export declare function findNonRowSpannedCell(apiRef: RefObject<GridPrivateApiCommunity>, rowId: GridRowId, colIndex: number, rowSpanScanDirection: 'up' | 'down'): GridRowId;
@@ -1,5 +1,5 @@
1
+ import { Rowspan } from '@mui/x-virtualizer';
1
2
  import { gridFilteredSortedRowIdsSelector } from "../filter/gridFilterSelector.js";
2
- import { gridRowSpanningHiddenCellsSelector } from "../rows/gridRowSpanningSelectors.js";
3
3
  export const getLeftColumnIndex = ({
4
4
  currentColIndex,
5
5
  firstColIndex,
@@ -34,9 +34,9 @@ export const getRightColumnIndex = ({
34
34
  }
35
35
  return null;
36
36
  };
37
- export function findNonRowSpannedCell(apiRef, rowId, field, rowSpanScanDirection) {
38
- const rowSpanHiddenCells = gridRowSpanningHiddenCellsSelector(apiRef);
39
- if (!rowSpanHiddenCells[rowId]?.[field]) {
37
+ export function findNonRowSpannedCell(apiRef, rowId, colIndex, rowSpanScanDirection) {
38
+ const rowSpanHiddenCells = Rowspan.selectors.hiddenCells(apiRef.current.virtualizer.store.state);
39
+ if (!rowSpanHiddenCells[rowId]?.[colIndex]) {
40
40
  return rowId;
41
41
  }
42
42
  const filteredSortedRowIds = gridFilteredSortedRowIdsSelector(apiRef);
@@ -44,7 +44,7 @@ export function findNonRowSpannedCell(apiRef, rowId, field, rowSpanScanDirection
44
44
  let nextRowIndex = filteredSortedRowIds.indexOf(rowId) + (rowSpanScanDirection === 'down' ? 1 : -1);
45
45
  while (nextRowIndex >= 0 && nextRowIndex < filteredSortedRowIds.length) {
46
46
  const nextRowId = filteredSortedRowIds[nextRowIndex];
47
- if (!rowSpanHiddenCells[nextRowId]?.[field]) {
47
+ if (!rowSpanHiddenCells[nextRowId]?.[colIndex]) {
48
48
  return nextRowId;
49
49
  }
50
50
  nextRowIndex += rowSpanScanDirection === 'down' ? 1 : -1;
@@ -1,7 +1,14 @@
1
1
  import { GridStateCommunity } from "../../../models/gridStateCommunity.js";
2
+ import type { GridStateColDef } from "../../../models/colDef/gridColDef.js";
3
+ /**
4
+ * Get the list view state
5
+ * @category List View
6
+ * @ignore - Do not document
7
+ */
8
+ export declare const gridListViewSelector: import("@mui/x-data-grid").OutputSelector<GridStateCommunity, unknown, boolean>;
2
9
  /**
3
10
  * Get the list column definition
4
11
  * @category List View
5
12
  * @ignore - Do not document
6
13
  */
7
- export declare const gridListColumnSelector: import("@mui/x-data-grid").OutputSelector<GridStateCommunity, unknown, import("./useGridListView.js").GridListViewState>;
14
+ export declare const gridListColumnSelector: import("@mui/x-data-grid").OutputSelector<GridStateCommunity, unknown, GridStateColDef>;
@@ -1,4 +1,11 @@
1
1
  import { createRootSelector } from "../../../utils/createSelector.js";
2
+ /**
3
+ * Get the list view state
4
+ * @category List View
5
+ * @ignore - Do not document
6
+ */
7
+ export const gridListViewSelector = createRootSelector(state => state.props.listView ?? false);
8
+
2
9
  /**
3
10
  * Get the list column definition
4
11
  * @category List View
@@ -2,7 +2,6 @@ import type { GridRowModelUpdate } from '@mui/x-data-grid';
2
2
  import type { GridColDef } from "../../../models/colDef/index.js";
3
3
  export interface GridPivotingStatePartial {
4
4
  active: boolean;
5
- panelOpen: boolean;
6
5
  initialColumns: Map<string, GridColDef> | undefined;
7
6
  }
8
7
  export interface GridPivotingPrivateApiCommunity {
@@ -5,7 +5,4 @@ export declare const gridPivotActiveSelector: (args_0: import("react").RefObject
5
5
  } | null>) => boolean;
6
6
  export declare const gridPivotInitialColumnsSelector: (args_0: import("react").RefObject<{
7
7
  state: GridStateCommunity;
8
- } | null>) => Map<string, GridColDef>;
9
- export declare const gridPivotPanelOpenSelector: (args_0: import("react").RefObject<{
10
- state: GridStateCommunity;
11
- } | null>) => boolean;
8
+ } | null>) => Map<string, GridColDef>;
@@ -4,5 +4,4 @@ const gridPivotingStateSelector = createRootSelector(
4
4
  state => state.pivoting);
5
5
  export const gridPivotActiveSelector = createSelector(gridPivotingStateSelector, pivoting => pivoting?.active);
6
6
  const emptyColumns = new Map();
7
- export const gridPivotInitialColumnsSelector = createSelector(gridPivotingStateSelector, pivoting => pivoting?.initialColumns || emptyColumns);
8
- export const gridPivotPanelOpenSelector = createSelector(gridPivotingStateSelector, pivoting => pivoting?.panelOpen);
7
+ export const gridPivotInitialColumnsSelector = createSelector(gridPivotingStateSelector, pivoting => pivoting?.initialColumns || emptyColumns);
@@ -299,12 +299,13 @@ export const useGridRowSelection = (apiRef, props) => {
299
299
  }
300
300
  const currentSelection = gridRowSelectionStateSelector(apiRef);
301
301
  const rowsLookup = gridRowsLookupSelector(apiRef);
302
+ const rowTree = gridRowTreeSelector(apiRef);
302
303
  const filteredRowsLookup = gridFilteredRowsLookupSelector(apiRef);
303
304
  const isNonExistent = id => {
304
305
  if (props.filterMode === 'server') {
305
306
  return !rowsLookup[id];
306
307
  }
307
- return !rowsLookup[id] || filteredRowsLookup[id] === false;
308
+ return !rowTree[id] || filteredRowsLookup[id] === false;
308
309
  };
309
310
  const newSelectionModel = {
310
311
  type: currentSelection.type,
@@ -430,15 +431,15 @@ export const useGridRowSelection = (apiRef, props) => {
430
431
  const filterModel = gridFilterModelSelector(apiRef);
431
432
  const quickFilterModel = gridQuickFilterValuesSelector(apiRef);
432
433
  const hasFilters = filterModel.items.length > 0 || quickFilterModel?.some(val => val.length);
433
- if (!props.isRowSelectable && !props.checkboxSelectionVisibleOnly && applyAutoSelection && !hasFilters) {
434
+ if (!props.isRowSelectable && !props.checkboxSelectionVisibleOnly && (!isNestedData || props.rowSelectionPropagation?.descendants) && !hasFilters) {
434
435
  apiRef.current.setRowSelectionModel({
435
436
  type: value ? 'exclude' : 'include',
436
437
  ids: new Set()
437
- });
438
+ }, 'multipleRowsSelection');
438
439
  } else {
439
440
  apiRef.current.selectRows(getRowsToBeSelected(), value);
440
441
  }
441
- }, [apiRef, applyAutoSelection, getRowsToBeSelected, props.checkboxSelectionVisibleOnly, props.isRowSelectable]);
442
+ }, [apiRef, getRowsToBeSelected, props.checkboxSelectionVisibleOnly, props.isRowSelectable, props.rowSelectionPropagation?.descendants, isNestedData]);
442
443
  const handleHeaderSelectionCheckboxChange = React.useCallback(params => {
443
444
  toggleAllRows(params.value);
444
445
  }, [toggleAllRows]);