@mui/x-data-grid 7.17.0 → 7.19.0

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 (203) hide show
  1. package/CHANGELOG.md +208 -5
  2. package/DataGrid/DataGrid.js +16 -1
  3. package/DataGrid/useDataGridComponent.js +3 -0
  4. package/DataGrid/useDataGridProps.js +2 -1
  5. package/components/GridRow.js +1 -0
  6. package/components/cell/GridCell.js +33 -9
  7. package/components/columnHeaders/GridBaseColumnHeaders.js +1 -1
  8. package/components/columnSelection/GridCellCheckboxRenderer.js +12 -4
  9. package/components/columnSelection/GridHeaderCheckbox.d.ts +1 -1
  10. package/components/containers/GridRoot.js +1 -1
  11. package/components/containers/GridRootStyles.js +32 -23
  12. package/components/containers/GridToolbarContainer.js +1 -1
  13. package/components/menu/GridMenu.js +1 -1
  14. package/components/panel/GridPanel.d.ts +1 -1
  15. package/components/panel/GridPanel.js +1 -1
  16. package/components/panel/GridPanelContent.js +1 -1
  17. package/components/panel/GridPanelFooter.js +1 -1
  18. package/components/panel/GridPanelHeader.js +1 -1
  19. package/components/panel/GridPanelWrapper.js +1 -1
  20. package/components/panel/filterPanel/filterPanelUtils.d.ts +1 -1
  21. package/components/toolbar/GridToolbarQuickFilter.js +1 -1
  22. package/components/virtualization/GridBottomContainer.d.ts +1 -1
  23. package/components/virtualization/GridBottomContainer.js +18 -1
  24. package/components/virtualization/GridMainContainer.js +3 -1
  25. package/components/virtualization/GridTopContainer.d.ts +1 -1
  26. package/components/virtualization/GridTopContainer.js +1 -1
  27. package/components/virtualization/GridVirtualScrollbar.js +1 -7
  28. package/components/virtualization/GridVirtualScroller.js +1 -0
  29. package/components/virtualization/GridVirtualScrollerFiller.js +3 -4
  30. package/hooks/features/columnGrouping/gridColumnGroupsSelector.d.ts +4 -4
  31. package/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +1 -2
  32. package/hooks/features/columnHeaders/useGridColumnHeaders.js +11 -11
  33. package/hooks/features/columnResize/columnResizeSelector.d.ts +1 -1
  34. package/hooks/features/columnResize/useGridColumnResize.js +6 -6
  35. package/hooks/features/columns/gridColumnsSelector.d.ts +12 -12
  36. package/hooks/features/columns/gridColumnsUtils.js +3 -2
  37. package/hooks/features/density/densitySelector.d.ts +1 -1
  38. package/hooks/features/dimensions/gridDimensionsApi.d.ts +4 -0
  39. package/hooks/features/dimensions/useGridDimensions.d.ts +1 -1
  40. package/hooks/features/dimensions/useGridDimensions.js +4 -1
  41. package/hooks/features/editing/useGridCellEditing.js +3 -19
  42. package/hooks/features/editing/useGridRowEditing.js +7 -2
  43. package/hooks/features/editing/utils.d.ts +2 -0
  44. package/hooks/features/editing/utils.js +15 -0
  45. package/hooks/features/export/useGridPrintExport.js +2 -1
  46. package/hooks/features/filter/gridFilterSelector.d.ts +17 -17
  47. package/hooks/features/focus/gridFocusStateSelector.d.ts +8 -8
  48. package/hooks/features/focus/useGridFocus.js +2 -1
  49. package/hooks/features/headerFiltering/gridHeaderFilteringSelectors.d.ts +3 -3
  50. package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +10 -46
  51. package/hooks/features/keyboardNavigation/utils.d.ts +17 -0
  52. package/hooks/features/keyboardNavigation/utils.js +58 -0
  53. package/hooks/features/pagination/gridPaginationSelector.d.ts +9 -9
  54. package/hooks/features/rowSelection/gridRowSelectionSelector.d.ts +3 -3
  55. package/hooks/features/rowSelection/useGridRowSelection.d.ts +1 -1
  56. package/hooks/features/rowSelection/useGridRowSelection.js +105 -29
  57. package/hooks/features/rowSelection/utils.d.ts +10 -0
  58. package/hooks/features/rowSelection/utils.js +156 -1
  59. package/hooks/features/rows/gridRowSpanningSelectors.d.ts +4 -0
  60. package/hooks/features/rows/gridRowSpanningSelectors.js +5 -0
  61. package/hooks/features/rows/gridRowSpanningUtils.d.ts +10 -0
  62. package/hooks/features/rows/gridRowSpanningUtils.js +42 -0
  63. package/hooks/features/rows/gridRowsSelector.d.ts +14 -14
  64. package/hooks/features/rows/useGridRowSpanning.d.ts +27 -0
  65. package/hooks/features/rows/useGridRowSpanning.js +257 -0
  66. package/hooks/features/rows/useGridRows.d.ts +1 -1
  67. package/hooks/features/rows/useGridRows.js +7 -1
  68. package/hooks/features/scroll/useGridScroll.js +19 -19
  69. package/hooks/features/sorting/gridSortingSelector.d.ts +4 -4
  70. package/hooks/features/virtualization/gridVirtualizationSelectors.d.ts +5 -5
  71. package/hooks/features/virtualization/useGridVirtualScroller.d.ts +1 -1
  72. package/hooks/features/virtualization/useGridVirtualScroller.js +17 -7
  73. package/hooks/utils/useGridApiEventHandler.js +0 -1
  74. package/hooks/utils/useGridVisibleRows.d.ts +2 -2
  75. package/index.js +1 -1
  76. package/internals/index.d.ts +2 -0
  77. package/internals/index.js +2 -0
  78. package/locales/bgBG.js +8 -9
  79. package/locales/deDE.js +4 -4
  80. package/locales/frFR.js +4 -4
  81. package/locales/hrHR.d.ts +1 -1
  82. package/locales/hrHR.js +69 -46
  83. package/locales/jaJP.js +1 -2
  84. package/locales/ptPT.d.ts +1 -1
  85. package/locales/ptPT.js +4 -4
  86. package/locales/viVN.js +20 -20
  87. package/locales/zhHK.d.ts +1 -1
  88. package/models/colDef/gridColDef.d.ts +4 -0
  89. package/models/gridRowSelectionModel.d.ts +4 -0
  90. package/models/gridStateCommunity.d.ts +2 -0
  91. package/models/props/DataGridProps.d.ts +30 -1
  92. package/modern/DataGrid/DataGrid.js +16 -1
  93. package/modern/DataGrid/useDataGridComponent.js +3 -0
  94. package/modern/DataGrid/useDataGridProps.js +2 -1
  95. package/modern/components/GridRow.js +1 -0
  96. package/modern/components/cell/GridCell.js +33 -9
  97. package/modern/components/columnHeaders/GridBaseColumnHeaders.js +1 -1
  98. package/modern/components/columnSelection/GridCellCheckboxRenderer.js +12 -4
  99. package/modern/components/containers/GridRoot.js +1 -1
  100. package/modern/components/containers/GridRootStyles.js +32 -23
  101. package/modern/components/containers/GridToolbarContainer.js +1 -1
  102. package/modern/components/menu/GridMenu.js +1 -1
  103. package/modern/components/panel/GridPanel.js +1 -1
  104. package/modern/components/panel/GridPanelContent.js +1 -1
  105. package/modern/components/panel/GridPanelFooter.js +1 -1
  106. package/modern/components/panel/GridPanelHeader.js +1 -1
  107. package/modern/components/panel/GridPanelWrapper.js +1 -1
  108. package/modern/components/toolbar/GridToolbarQuickFilter.js +1 -1
  109. package/modern/components/virtualization/GridBottomContainer.js +18 -1
  110. package/modern/components/virtualization/GridMainContainer.js +3 -1
  111. package/modern/components/virtualization/GridTopContainer.js +1 -1
  112. package/modern/components/virtualization/GridVirtualScrollbar.js +1 -7
  113. package/modern/components/virtualization/GridVirtualScroller.js +1 -0
  114. package/modern/components/virtualization/GridVirtualScrollerFiller.js +3 -4
  115. package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +11 -11
  116. package/modern/hooks/features/columnResize/useGridColumnResize.js +6 -6
  117. package/modern/hooks/features/columns/gridColumnsUtils.js +3 -2
  118. package/modern/hooks/features/dimensions/useGridDimensions.js +4 -1
  119. package/modern/hooks/features/editing/useGridCellEditing.js +3 -19
  120. package/modern/hooks/features/editing/useGridRowEditing.js +7 -2
  121. package/modern/hooks/features/editing/utils.js +15 -0
  122. package/modern/hooks/features/export/useGridPrintExport.js +2 -1
  123. package/modern/hooks/features/focus/useGridFocus.js +2 -1
  124. package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +10 -46
  125. package/modern/hooks/features/keyboardNavigation/utils.js +58 -0
  126. package/modern/hooks/features/rowSelection/useGridRowSelection.js +105 -29
  127. package/modern/hooks/features/rowSelection/utils.js +156 -1
  128. package/modern/hooks/features/rows/gridRowSpanningSelectors.js +5 -0
  129. package/modern/hooks/features/rows/gridRowSpanningUtils.js +42 -0
  130. package/modern/hooks/features/rows/useGridRowSpanning.js +257 -0
  131. package/modern/hooks/features/rows/useGridRows.js +7 -1
  132. package/modern/hooks/features/scroll/useGridScroll.js +19 -19
  133. package/modern/hooks/features/virtualization/useGridVirtualScroller.js +17 -7
  134. package/modern/hooks/utils/useGridApiEventHandler.js +0 -1
  135. package/modern/index.js +1 -1
  136. package/modern/internals/index.js +2 -0
  137. package/modern/locales/bgBG.js +8 -9
  138. package/modern/locales/deDE.js +4 -4
  139. package/modern/locales/frFR.js +4 -4
  140. package/modern/locales/hrHR.js +69 -46
  141. package/modern/locales/jaJP.js +1 -2
  142. package/modern/locales/ptPT.js +4 -4
  143. package/modern/locales/viVN.js +20 -20
  144. package/modern/utils/createSelector.js +6 -0
  145. package/modern/utils/domUtils.js +12 -12
  146. package/node/DataGrid/DataGrid.js +16 -1
  147. package/node/DataGrid/useDataGridComponent.js +3 -0
  148. package/node/DataGrid/useDataGridProps.js +2 -1
  149. package/node/components/GridRow.js +1 -0
  150. package/node/components/cell/GridCell.js +33 -9
  151. package/node/components/columnHeaders/GridBaseColumnHeaders.js +1 -1
  152. package/node/components/columnSelection/GridCellCheckboxRenderer.js +12 -4
  153. package/node/components/containers/GridRoot.js +1 -1
  154. package/node/components/containers/GridRootStyles.js +32 -23
  155. package/node/components/containers/GridToolbarContainer.js +1 -1
  156. package/node/components/menu/GridMenu.js +1 -1
  157. package/node/components/panel/GridPanel.js +1 -1
  158. package/node/components/panel/GridPanelContent.js +1 -1
  159. package/node/components/panel/GridPanelFooter.js +1 -1
  160. package/node/components/panel/GridPanelHeader.js +1 -1
  161. package/node/components/panel/GridPanelWrapper.js +1 -1
  162. package/node/components/toolbar/GridToolbarQuickFilter.js +1 -1
  163. package/node/components/virtualization/GridBottomContainer.js +18 -1
  164. package/node/components/virtualization/GridMainContainer.js +3 -1
  165. package/node/components/virtualization/GridTopContainer.js +1 -1
  166. package/node/components/virtualization/GridVirtualScrollbar.js +1 -7
  167. package/node/components/virtualization/GridVirtualScroller.js +1 -0
  168. package/node/components/virtualization/GridVirtualScrollerFiller.js +3 -4
  169. package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +11 -11
  170. package/node/hooks/features/columnResize/useGridColumnResize.js +6 -6
  171. package/node/hooks/features/columns/gridColumnsUtils.js +3 -2
  172. package/node/hooks/features/dimensions/useGridDimensions.js +4 -1
  173. package/node/hooks/features/editing/useGridCellEditing.js +3 -19
  174. package/node/hooks/features/editing/useGridRowEditing.js +7 -2
  175. package/node/hooks/features/editing/utils.js +22 -0
  176. package/node/hooks/features/export/useGridPrintExport.js +2 -1
  177. package/node/hooks/features/focus/useGridFocus.js +2 -1
  178. package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +16 -53
  179. package/node/hooks/features/keyboardNavigation/utils.js +68 -0
  180. package/node/hooks/features/rowSelection/useGridRowSelection.js +102 -26
  181. package/node/hooks/features/rowSelection/utils.js +160 -1
  182. package/node/hooks/features/rows/gridRowSpanningSelectors.js +11 -0
  183. package/node/hooks/features/rows/gridRowSpanningUtils.js +52 -0
  184. package/node/hooks/features/rows/useGridRowSpanning.js +267 -0
  185. package/node/hooks/features/rows/useGridRows.js +7 -1
  186. package/node/hooks/features/scroll/useGridScroll.js +19 -19
  187. package/node/hooks/features/virtualization/useGridVirtualScroller.js +17 -7
  188. package/node/hooks/utils/useGridApiEventHandler.js +0 -1
  189. package/node/index.js +1 -1
  190. package/node/internals/index.js +38 -15
  191. package/node/locales/bgBG.js +8 -9
  192. package/node/locales/deDE.js +4 -4
  193. package/node/locales/frFR.js +4 -4
  194. package/node/locales/hrHR.js +69 -46
  195. package/node/locales/jaJP.js +1 -2
  196. package/node/locales/ptPT.js +4 -4
  197. package/node/locales/viVN.js +20 -20
  198. package/node/utils/createSelector.js +6 -0
  199. package/node/utils/domUtils.js +12 -12
  200. package/package.json +3 -3
  201. package/utils/createSelector.js +6 -0
  202. package/utils/domUtils.d.ts +4 -4
  203. package/utils/domUtils.js +12 -12
@@ -1,12 +1,14 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- const _excluded = ["field", "id", "value", "formattedValue", "row", "rowNode", "colDef", "isEditable", "cellMode", "hasFocus", "tabIndex", "api"];
3
+ const _excluded = ["field", "id", "formattedValue", "row", "rowNode", "colDef", "isEditable", "cellMode", "hasFocus", "tabIndex", "api"];
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import { unstable_composeClasses as composeClasses, unstable_useForkRef as useForkRef } from '@mui/utils';
7
7
  import { useGridApiContext } from "../../hooks/utils/useGridApiContext.js";
8
8
  import { useGridRootProps } from "../../hooks/utils/useGridRootProps.js";
9
9
  import { getDataGridUtilityClass } from "../../constants/gridClasses.js";
10
+ import { useGridSelector } from "../../hooks/utils/useGridSelector.js";
11
+ import { getCheckboxPropsSelector } from "../../hooks/features/rowSelection/utils.js";
10
12
  import { jsx as _jsx } from "react/jsx-runtime";
11
13
  const useUtilityClasses = ownerState => {
12
14
  const {
@@ -21,7 +23,6 @@ const GridCellCheckboxForwardRef = /*#__PURE__*/React.forwardRef(function GridCe
21
23
  const {
22
24
  field,
23
25
  id,
24
- value: isChecked,
25
26
  rowNode,
26
27
  hasFocus,
27
28
  tabIndex
@@ -69,21 +70,28 @@ const GridCellCheckboxForwardRef = /*#__PURE__*/React.forwardRef(function GridCe
69
70
  event.stopPropagation();
70
71
  }
71
72
  }, []);
73
+ const isSelectable = apiRef.current.isRowSelectable(id);
74
+ const checkboxPropsSelector = getCheckboxPropsSelector(id, rootProps.rowSelectionPropagation?.parents ?? false);
75
+ const {
76
+ isIndeterminate,
77
+ isChecked
78
+ } = useGridSelector(apiRef, checkboxPropsSelector);
72
79
  if (rowNode.type === 'footer' || rowNode.type === 'pinnedRow') {
73
80
  return null;
74
81
  }
75
- const isSelectable = apiRef.current.isRowSelectable(id);
76
82
  const label = apiRef.current.getLocaleText(isChecked ? 'checkboxSelectionUnselectRow' : 'checkboxSelectionSelectRow');
83
+ const checked = rootProps.indeterminateCheckboxAction === 'select' ? isChecked && !isIndeterminate : isChecked;
77
84
  return /*#__PURE__*/_jsx(rootProps.slots.baseCheckbox, _extends({
78
85
  ref: handleRef,
79
86
  tabIndex: tabIndex,
80
- checked: isChecked,
87
+ checked: checked,
81
88
  onChange: handleChange,
82
89
  className: classes.root,
83
90
  inputProps: {
84
91
  'aria-label': label
85
92
  },
86
93
  onKeyDown: handleKeyDown,
94
+ indeterminate: isIndeterminate,
87
95
  disabled: !isSelectable,
88
96
  touchRippleRef: rippleRef /* FIXME: typing error */
89
97
  }, rootProps.slotProps?.baseCheckbox, other));
@@ -46,7 +46,7 @@ const GridRoot = /*#__PURE__*/React.forwardRef(function GridRoot(props, ref) {
46
46
  }
47
47
  return /*#__PURE__*/_jsx(GridRootStyles, _extends({
48
48
  ref: handleRef,
49
- className: clsx(className, classes.root),
49
+ className: clsx(classes.root, className),
50
50
  ownerState: ownerState
51
51
  }, other));
52
52
  });
@@ -170,14 +170,28 @@ export const GridRootStyles = styled('div', {
170
170
  const hoverOpacity = (t.vars || t).palette.action.hoverOpacity;
171
171
  const hoverColor = (t.vars || t).palette.action.hover;
172
172
  const selectedOpacity = (t.vars || t).palette.action.selectedOpacity;
173
+ const selectedHoverOpacity = t.vars ? `calc(${hoverOpacity} + ${selectedOpacity})` // TODO: Improve type
174
+ : hoverOpacity + selectedOpacity;
173
175
  const selectedBackground = t.vars ? `rgba(${t.vars.palette.primary.mainChannel} / ${selectedOpacity})` : alpha(t.palette.primary.main, selectedOpacity);
174
- const selectedHoverBackground = t.vars ? `rgba(${t.vars.palette.primary.mainChannel} / calc(
175
- ${t.vars.palette.action.selectedOpacity} +
176
- ${t.vars.palette.action.hoverOpacity}
177
- ))` : alpha(t.palette.primary.main, t.palette.action.selectedOpacity + t.palette.action.hoverOpacity);
178
- const pinnedHoverBackground = t.vars ? hoverColor : blend(pinnedBackground, hoverColor, hoverOpacity);
179
- const pinnedSelectedBackground = t.vars ? selectedBackground : blend(pinnedBackground, selectedBackground, selectedOpacity);
180
- const pinnedSelectedHoverBackground = t.vars ? hoverColor : blend(pinnedSelectedBackground, hoverColor, hoverOpacity);
176
+ const selectedHoverBackground = t.vars ? `rgba(${t.vars.palette.primary.mainChannel} / ${selectedHoverOpacity})` : alpha(t.palette.primary.main, selectedHoverOpacity);
177
+ const blendFn = t.vars ? blendCssVars : blend;
178
+ const getPinnedBackgroundStyles = backgroundColor => ({
179
+ [`& .${c['cell--pinnedLeft']}, & .${c['cell--pinnedRight']}`]: {
180
+ backgroundColor,
181
+ '&.Mui-selected': {
182
+ backgroundColor: blendFn(backgroundColor, selectedBackground, selectedOpacity),
183
+ '&:hover': {
184
+ backgroundColor: blendFn(backgroundColor, selectedBackground, selectedHoverOpacity)
185
+ }
186
+ }
187
+ }
188
+ });
189
+ const pinnedBackgroundColor = blendFn(pinnedBackground, hoverColor, hoverOpacity);
190
+ const pinnedHoverStyles = getPinnedBackgroundStyles(pinnedBackgroundColor);
191
+ const pinnedSelectedBackgroundColor = blendFn(pinnedBackground, selectedBackground, selectedOpacity);
192
+ const pinnedSelectedStyles = getPinnedBackgroundStyles(pinnedSelectedBackgroundColor);
193
+ const pinnedSelectedHoverBackgroundColor = blendFn(pinnedBackground, selectedHoverBackground, selectedHoverOpacity);
194
+ const pinnedSelectedHoverStyles = getPinnedBackgroundStyles(pinnedSelectedHoverBackgroundColor);
181
195
  const selectedStyles = {
182
196
  backgroundColor: selectedBackground,
183
197
  '&:hover': {
@@ -617,24 +631,15 @@ export const GridRootStyles = styled('div', {
617
631
  [`& .${c['cell--pinnedLeft']}, & .${c['cell--pinnedRight']}`]: {
618
632
  position: 'sticky',
619
633
  zIndex: 3,
620
- background: 'var(--DataGrid-pinnedBackground)'
634
+ background: 'var(--DataGrid-pinnedBackground)',
635
+ '&.Mui-selected': {
636
+ backgroundColor: pinnedSelectedBackgroundColor
637
+ }
621
638
  },
622
639
  [`& .${c.virtualScrollerContent} .${c.row}`]: {
623
- '&:hover': {
624
- [`& .${c['cell--pinnedLeft']}, & .${c['cell--pinnedRight']}`]: {
625
- backgroundColor: pinnedHoverBackground
626
- }
627
- },
628
- [`&.Mui-selected`]: {
629
- [`& .${c['cell--pinnedLeft']}, & .${c['cell--pinnedRight']}`]: {
630
- backgroundColor: pinnedSelectedBackground
631
- },
632
- '&:hover': {
633
- [`& .${c['cell--pinnedLeft']}, & .${c['cell--pinnedRight']}`]: {
634
- backgroundColor: pinnedSelectedHoverBackground
635
- }
636
- }
637
- }
640
+ '&:hover': pinnedHoverStyles,
641
+ '&.Mui-selected': pinnedSelectedStyles,
642
+ '&.Mui-selected:hover': pinnedSelectedHoverStyles
638
643
  },
639
644
  [`& .${c.cellOffsetLeft}`]: {
640
645
  flex: '0 0 auto',
@@ -747,4 +752,8 @@ function blend(background, overlay, opacity, gamma = 1) {
747
752
  type: 'rgb',
748
753
  values: rgb
749
754
  });
755
+ }
756
+ const removeOpacity = color => `rgb(from ${color} r g b / 1)`;
757
+ function blendCssVars(background, overlay, opacity) {
758
+ return `color-mix(in srgb,${background}, ${removeOpacity(overlay)} calc(${opacity} * 100%))`;
750
759
  }
@@ -44,7 +44,7 @@ const GridToolbarContainer = /*#__PURE__*/React.forwardRef(function GridToolbarC
44
44
  }
45
45
  return /*#__PURE__*/_jsx(GridToolbarContainerRoot, _extends({
46
46
  ref: ref,
47
- className: clsx(className, classes.root),
47
+ className: clsx(classes.root, className),
48
48
  ownerState: rootProps
49
49
  }, other, {
50
50
  children: children
@@ -85,7 +85,7 @@ function GridMenu(props) {
85
85
  };
86
86
  return /*#__PURE__*/_jsx(GridMenuRoot, _extends({
87
87
  as: rootProps.slots.basePopper,
88
- className: clsx(className, classes.root),
88
+ className: clsx(classes.root, className),
89
89
  ownerState: rootProps,
90
90
  open: open,
91
91
  anchorEl: target,
@@ -84,7 +84,7 @@ const GridPanel = /*#__PURE__*/React.forwardRef((props, ref) => {
84
84
  return /*#__PURE__*/_jsx(GridPanelRoot, _extends({
85
85
  ref: ref,
86
86
  placement: "bottom-start",
87
- className: clsx(className, classes.panel),
87
+ className: clsx(classes.panel, className),
88
88
  ownerState: rootProps,
89
89
  anchorEl: anchorEl,
90
90
  modifiers: modifiers
@@ -37,7 +37,7 @@ function GridPanelContent(props) {
37
37
  const rootProps = useGridRootProps();
38
38
  const classes = useUtilityClasses(rootProps);
39
39
  return /*#__PURE__*/_jsx(GridPanelContentRoot, _extends({
40
- className: clsx(className, classes.root),
40
+ className: clsx(classes.root, className),
41
41
  ownerState: rootProps
42
42
  }, other));
43
43
  }
@@ -37,7 +37,7 @@ function GridPanelFooter(props) {
37
37
  const rootProps = useGridRootProps();
38
38
  const classes = useUtilityClasses(rootProps);
39
39
  return /*#__PURE__*/_jsx(GridPanelFooterRoot, _extends({
40
- className: clsx(className, classes.root),
40
+ className: clsx(classes.root, className),
41
41
  ownerState: rootProps
42
42
  }, other));
43
43
  }
@@ -35,7 +35,7 @@ function GridPanelHeader(props) {
35
35
  const rootProps = useGridRootProps();
36
36
  const classes = useUtilityClasses(rootProps);
37
37
  return /*#__PURE__*/_jsx(GridPanelHeaderRoot, _extends({
38
- className: clsx(className, classes.root),
38
+ className: clsx(classes.root, className),
39
39
  ownerState: rootProps
40
40
  }, other));
41
41
  }
@@ -48,7 +48,7 @@ const GridPanelWrapper = /*#__PURE__*/React.forwardRef(function GridPanelWrapper
48
48
  children: /*#__PURE__*/_jsx(GridPanelWrapperRoot, _extends({
49
49
  ref: ref,
50
50
  tabIndex: -1,
51
- className: clsx(className, classes.root),
51
+ className: clsx(classes.root, className),
52
52
  ownerState: rootProps
53
53
  }, other))
54
54
  }));
@@ -93,7 +93,7 @@ function GridToolbarQuickFilter(props) {
93
93
  variant: "standard",
94
94
  value: searchValue,
95
95
  onChange: handleSearchValueChange,
96
- className: clsx(className, classes.root),
96
+ className: clsx(classes.root, className),
97
97
  placeholder: apiRef.current.getLocaleText('toolbarQuickFilterPlaceholder'),
98
98
  "aria-label": apiRef.current.getLocaleText('toolbarQuickFilterLabel'),
99
99
  type: "search"
@@ -4,6 +4,9 @@ import clsx from 'clsx';
4
4
  import { styled } from '@mui/system';
5
5
  import composeClasses from '@mui/utils/composeClasses';
6
6
  import { gridClasses, getDataGridUtilityClass } from "../../constants/gridClasses.js";
7
+ import { gridDimensionsSelector } from "../../hooks/features/dimensions/gridDimensionsSelectors.js";
8
+ import { useGridApiContext } from "../../hooks/utils/useGridApiContext.js";
9
+ import { useGridSelector } from "../../hooks/utils/useGridSelector.js";
7
10
  import { jsx as _jsx } from "react/jsx-runtime";
8
11
  const useUtilityClasses = () => {
9
12
  const slots = {
@@ -18,8 +21,22 @@ const Element = styled('div')({
18
21
  });
19
22
  export function GridBottomContainer(props) {
20
23
  const classes = useUtilityClasses();
24
+ const apiRef = useGridApiContext();
25
+ const {
26
+ viewportOuterSize,
27
+ minimumSize,
28
+ hasScrollX,
29
+ scrollbarSize
30
+ } = useGridSelector(apiRef, gridDimensionsSelector);
31
+ const scrollHeight = hasScrollX ? scrollbarSize : 0;
32
+ const offset = Math.max(viewportOuterSize.height - minimumSize.height -
33
+ // Subtract scroll height twice to account for GridVirtualScrollerFiller and horizontal scrollbar
34
+ 2 * scrollHeight, 0);
21
35
  return /*#__PURE__*/_jsx(Element, _extends({}, props, {
22
- className: clsx(classes.root, props.className, gridClasses['container--bottom']),
36
+ className: clsx(classes.root, gridClasses['container--bottom']),
37
+ style: {
38
+ transform: `translateY(${offset}px)`
39
+ },
23
40
  role: "presentation"
24
41
  }));
25
42
  }
@@ -16,7 +16,9 @@ const Element = styled('div', {
16
16
  })({
17
17
  flexGrow: 1,
18
18
  position: 'relative',
19
- overflow: 'hidden'
19
+ overflow: 'hidden',
20
+ display: 'flex',
21
+ flexDirection: 'column'
20
22
  });
21
23
  export const GridMainContainer = /*#__PURE__*/React.forwardRef((props, ref) => {
22
24
  const rootProps = useGridRootProps();
@@ -19,7 +19,7 @@ const Element = styled('div')({
19
19
  export function GridTopContainer(props) {
20
20
  const classes = useUtilityClasses();
21
21
  return /*#__PURE__*/_jsx(Element, _extends({}, props, {
22
- className: clsx(classes.root, props.className, gridClasses['container--top']),
22
+ className: clsx(classes.root, gridClasses['container--top']),
23
23
  role: "presentation"
24
24
  }));
25
25
  }
@@ -21,9 +21,6 @@ const Scrollbar = styled('div')({
21
21
  position: 'absolute',
22
22
  display: 'inline-block',
23
23
  zIndex: 6,
24
- '& > div': {
25
- display: 'inline-block'
26
- },
27
24
  // In macOS Safari and Gnome Web, scrollbars are overlaid and don't affect the layout. So we consider
28
25
  // their size to be 0px throughout all the calculations, but the floating scrollbar container does need
29
26
  // to appear and have a real size. We set it to 14px because it seems like an acceptable value and we
@@ -55,9 +52,6 @@ const ScrollbarHorizontal = styled(Scrollbar)({
55
52
  },
56
53
  bottom: '0px'
57
54
  });
58
- const Content = styled('div')({
59
- display: 'inline-block'
60
- });
61
55
  const GridVirtualScrollbar = /*#__PURE__*/React.forwardRef(function GridVirtualScrollbar(props, ref) {
62
56
  const apiRef = useGridPrivateApiContext();
63
57
  const rootProps = useGridRootProps();
@@ -127,7 +121,7 @@ const GridVirtualScrollbar = /*#__PURE__*/React.forwardRef(function GridVirtualS
127
121
  className: classes.root,
128
122
  tabIndex: -1,
129
123
  "aria-hidden": "true",
130
- children: /*#__PURE__*/_jsx(Content, {
124
+ children: /*#__PURE__*/_jsx("div", {
131
125
  ref: contentRef,
132
126
  className: classes.content
133
127
  })
@@ -37,6 +37,7 @@ const Scroller = styled('div', {
37
37
  })({
38
38
  position: 'relative',
39
39
  height: '100%',
40
+ flexGrow: 1,
40
41
  overflow: 'scroll',
41
42
  scrollbarWidth: 'none' /* Firefox */,
42
43
  '&::-webkit-scrollbar': {
@@ -44,10 +44,9 @@ function GridVirtualScrollerFiller({
44
44
  leftPinnedWidth,
45
45
  rightPinnedWidth
46
46
  } = useGridSelector(apiRef, gridDimensionsSelector);
47
- const scrollbarHeight = hasScrollX ? scrollbarSize : 0;
48
- const expandedHeight = viewportOuterSize.height - minimumSize.height - scrollbarHeight;
49
- const height = Math.max(scrollbarHeight, expandedHeight);
50
- if (height === 0) {
47
+ const height = hasScrollX ? scrollbarSize : 0;
48
+ const needsLastRowBorder = viewportOuterSize.height - minimumSize.height > 0;
49
+ if (height === 0 && !needsLastRowBorder) {
51
50
  return null;
52
51
  }
53
52
  return /*#__PURE__*/_jsxs(Filler, {
@@ -53,7 +53,7 @@ export const useGridColumnHeaders = props => {
53
53
  const renderContext = useGridSelector(apiRef, gridRenderContextColumnsSelector);
54
54
  const pinnedColumns = useGridSelector(apiRef, gridVisiblePinnedColumnDefinitionsSelector);
55
55
  const columnsLookup = useGridSelector(apiRef, gridColumnLookupSelector);
56
- const offsetLeft = computeOffsetLeft(columnPositions, renderContext, isRtl, pinnedColumns.left.length);
56
+ const offsetLeft = computeOffsetLeft(columnPositions, renderContext, pinnedColumns.left.length);
57
57
  const gridHasFiller = dimensions.columnsTotalWidth < dimensions.viewportOuterSize.width;
58
58
  React.useEffect(() => {
59
59
  apiRef.current.columnHeadersContainerRef.current.scrollLeft = 0;
@@ -83,7 +83,6 @@ export const useGridColumnHeaders = props => {
83
83
  const getColumnsToRender = params => {
84
84
  const {
85
85
  renderContext: currentContext = renderContext,
86
- // TODO: `minFirstColumn` is not used anymore, could be refactored out.
87
86
  maxLastColumn = visibleColumns.length
88
87
  } = params || {};
89
88
  const firstColumnToRender = currentContext.firstColumnIndex;
@@ -123,16 +122,22 @@ export const useGridColumnHeaders = props => {
123
122
  computedWidth
124
123
  }) => {
125
124
  let style;
126
- if (pinnedPosition === 'left' || pinnedPosition === 'right') {
125
+ const isLeftPinned = pinnedPosition === GridPinnedColumnPosition.LEFT;
126
+ const isRightPinned = pinnedPosition === GridPinnedColumnPosition.RIGHT;
127
+ if (isLeftPinned || isRightPinned) {
127
128
  const pinnedOffset = getPinnedCellOffset(pinnedPosition, computedWidth, columnIndex, columnPositions, dimensions);
129
+ let side = isLeftPinned ? 'left' : 'right';
130
+ if (isRtl) {
131
+ side = isLeftPinned ? 'right' : 'left';
132
+ }
128
133
  if (pinnedPosition === 'left') {
129
134
  style = {
130
- left: pinnedOffset
135
+ [side]: pinnedOffset
131
136
  };
132
137
  }
133
138
  if (pinnedPosition === 'right') {
134
139
  style = {
135
- right: pinnedOffset
140
+ [side]: pinnedOffset
136
141
  };
137
142
  }
138
143
  }
@@ -191,18 +196,15 @@ export const useGridColumnHeaders = props => {
191
196
  children: [leftRenderContext && getColumnHeaders({
192
197
  position: GridPinnedColumnPosition.LEFT,
193
198
  renderContext: leftRenderContext,
194
- minFirstColumn: leftRenderContext.firstColumnIndex,
195
199
  maxLastColumn: leftRenderContext.lastColumnIndex
196
200
  }, {
197
201
  disableReorder: true
198
202
  }), getColumnHeaders({
199
203
  renderContext,
200
- minFirstColumn: pinnedColumns.left.length,
201
204
  maxLastColumn: visibleColumns.length - pinnedColumns.right.length
202
205
  }), rightRenderContext && getColumnHeaders({
203
206
  position: GridPinnedColumnPosition.RIGHT,
204
207
  renderContext: rightRenderContext,
205
- minFirstColumn: rightRenderContext.firstColumnIndex,
206
208
  maxLastColumn: rightRenderContext.lastColumnIndex
207
209
  }, {
208
210
  disableReorder: true,
@@ -282,7 +284,7 @@ export const useGridColumnHeaders = props => {
282
284
  depth: depth,
283
285
  isLastColumn: headerInfo.colIndex === visibleColumns.length - headerInfo.fields.length,
284
286
  maxDepth: headerGroupingMaxDepth,
285
- height: dimensions.headerHeight,
287
+ height: dimensions.groupHeaderHeight,
286
288
  hasFocus: hasFocus,
287
289
  tabIndex: tabIndex,
288
290
  pinnedPosition: pinnedPosition,
@@ -309,7 +311,6 @@ export const useGridColumnHeaders = props => {
309
311
  params: {
310
312
  position: GridPinnedColumnPosition.LEFT,
311
313
  renderContext: leftRenderContext,
312
- minFirstColumn: leftRenderContext.firstColumnIndex,
313
314
  maxLastColumn: leftRenderContext.lastColumnIndex
314
315
  }
315
316
  }), getColumnGroupHeaders({
@@ -322,7 +323,6 @@ export const useGridColumnHeaders = props => {
322
323
  params: {
323
324
  position: GridPinnedColumnPosition.RIGHT,
324
325
  renderContext: rightRenderContext,
325
- minFirstColumn: rightRenderContext.firstColumnIndex,
326
326
  maxLastColumn: rightRenderContext.lastColumnIndex
327
327
  }
328
328
  })]
@@ -302,13 +302,13 @@ export const useGridColumnResize = (apiRef, props) => {
302
302
  }
303
303
  refs.groupHeaderElements = findGroupHeaderElementsFromField(apiRef.current.columnHeadersContainerRef?.current, colDef.field);
304
304
  refs.cellElements = findGridCellElementsFromCol(refs.columnHeaderElement, apiRef.current);
305
- refs.fillerLeft = findGridElement(apiRef.current, 'filler--pinnedLeft');
306
- refs.fillerRight = findGridElement(apiRef.current, 'filler--pinnedRight');
305
+ refs.fillerLeft = findGridElement(apiRef.current, isRtl ? 'filler--pinnedRight' : 'filler--pinnedLeft');
306
+ refs.fillerRight = findGridElement(apiRef.current, isRtl ? 'filler--pinnedLeft' : 'filler--pinnedRight');
307
307
  const pinnedPosition = apiRef.current.unstable_applyPipeProcessors('isColumnPinned', false, refs.colDef.field);
308
- refs.leftPinnedCellsAfter = pinnedPosition !== GridPinnedColumnPosition.LEFT ? [] : findLeftPinnedCellsAfterCol(apiRef.current, refs.columnHeaderElement);
309
- refs.rightPinnedCellsBefore = pinnedPosition !== GridPinnedColumnPosition.RIGHT ? [] : findRightPinnedCellsBeforeCol(apiRef.current, refs.columnHeaderElement);
310
- refs.leftPinnedHeadersAfter = pinnedPosition !== GridPinnedColumnPosition.LEFT ? [] : findLeftPinnedHeadersAfterCol(apiRef.current, refs.columnHeaderElement);
311
- refs.rightPinnedHeadersBefore = pinnedPosition !== GridPinnedColumnPosition.RIGHT ? [] : findRightPinnedHeadersBeforeCol(apiRef.current, refs.columnHeaderElement);
308
+ refs.leftPinnedCellsAfter = pinnedPosition !== GridPinnedColumnPosition.LEFT ? [] : findLeftPinnedCellsAfterCol(apiRef.current, refs.columnHeaderElement, isRtl);
309
+ refs.rightPinnedCellsBefore = pinnedPosition !== GridPinnedColumnPosition.RIGHT ? [] : findRightPinnedCellsBeforeCol(apiRef.current, refs.columnHeaderElement, isRtl);
310
+ refs.leftPinnedHeadersAfter = pinnedPosition !== GridPinnedColumnPosition.LEFT ? [] : findLeftPinnedHeadersAfterCol(apiRef.current, refs.columnHeaderElement, isRtl);
311
+ refs.rightPinnedHeadersBefore = pinnedPosition !== GridPinnedColumnPosition.RIGHT ? [] : findRightPinnedHeadersBeforeCol(apiRef.current, refs.columnHeaderElement, isRtl);
312
312
  resizeDirection.current = getResizeDirection(separator, isRtl);
313
313
  initialOffsetToSeparator.current = computeOffsetToSeparator(xStart, refs.columnHeaderElement.getBoundingClientRect(), resizeDirection.current);
314
314
  };
@@ -1,4 +1,5 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import resolveProps from '@mui/utils/resolveProps';
2
3
  import { DEFAULT_GRID_COL_TYPE_KEY, GRID_STRING_COL_DEF, getGridDefaultColumnTypes } from "../../../colDef/index.js";
3
4
  import { gridColumnsStateSelector, gridColumnVisibilityModelSelector } from "./gridColumnsSelector.js";
4
5
  import { clamp } from "../../../utils/utils.js";
@@ -275,9 +276,9 @@ export const createColumnsState = ({
275
276
  }
276
277
  }
277
278
  });
278
- columnsState.lookup[field] = _extends({}, existingState, newColumn, {
279
+ columnsState.lookup[field] = resolveProps(existingState, _extends({}, newColumn, {
279
280
  hasBeenResized
280
- });
281
+ }));
281
282
  });
282
283
  if (keepOnlyColumnsToUpsert && !isInsideStateInitializer) {
283
284
  Object.keys(columnsState.lookup).forEach(field => {
@@ -29,6 +29,7 @@ const EMPTY_DIMENSIONS = {
29
29
  hasScrollY: false,
30
30
  scrollbarSize: 0,
31
31
  headerHeight: 0,
32
+ groupHeaderHeight: 0,
32
33
  headerFilterHeight: 0,
33
34
  rowWidth: 0,
34
35
  rowHeight: 0,
@@ -55,6 +56,7 @@ export function useGridDimensions(apiRef, props) {
55
56
  const densityFactor = useGridSelector(apiRef, gridDensityFactorSelector);
56
57
  const rowHeight = Math.floor(props.rowHeight * densityFactor);
57
58
  const headerHeight = Math.floor(props.columnHeaderHeight * densityFactor);
59
+ const groupHeaderHeight = Math.floor((props.columnGroupHeaderHeight ?? props.columnHeaderHeight) * densityFactor);
58
60
  const headerFilterHeight = Math.floor((props.headerFilterHeight ?? props.columnHeaderHeight) * densityFactor);
59
61
  const columnsTotalWidth = roundToDecimalPlaces(gridColumnsTotalWidthSelector(apiRef), 6);
60
62
  const headersTotalHeight = getTotalHeaderHeight(apiRef, props);
@@ -175,6 +177,7 @@ export function useGridDimensions(apiRef, props) {
175
177
  hasScrollY,
176
178
  scrollbarSize,
177
179
  headerHeight,
180
+ groupHeaderHeight,
178
181
  headerFilterHeight,
179
182
  rowWidth,
180
183
  rowHeight,
@@ -191,7 +194,7 @@ export function useGridDimensions(apiRef, props) {
191
194
  apiRef.current.publishEvent('viewportInnerSizeChange', newDimensions.viewportInnerSize);
192
195
  }
193
196
  apiRef.current.updateRenderContext?.();
194
- }, [apiRef, setDimensions, props.scrollbarSize, props.autoHeight, rowsMeta.currentPageTotalHeight, rowHeight, headerHeight, headerFilterHeight, columnsTotalWidth, headersTotalHeight, leftPinnedWidth, rightPinnedWidth]);
197
+ }, [apiRef, setDimensions, props.scrollbarSize, props.autoHeight, rowsMeta.currentPageTotalHeight, rowHeight, headerHeight, groupHeaderHeight, headerFilterHeight, columnsTotalWidth, headersTotalHeight, leftPinnedWidth, rightPinnedWidth]);
195
198
  const apiPublic = {
196
199
  resize,
197
200
  getRootDimensions
@@ -14,6 +14,7 @@ import { isPrintableKey, isPasteShortcut } from "../../../utils/keyboardUtils.js
14
14
  import { gridRowsDataRowIdToIdLookupSelector } from "../rows/gridRowsSelector.js";
15
15
  import { deepClone } from "../../../utils/utils.js";
16
16
  import { GridCellEditStartReasons, GridCellEditStopReasons } from "../../../models/params/gridEditCellParams.js";
17
+ import { getDefaultCellValue } from "./utils.js";
17
18
  export const useGridCellEditing = (apiRef, props) => {
18
19
  const [cellModesModel, setCellModesModel] = React.useState({});
19
20
  const cellModesModelRef = React.useRef(cellModesModel);
@@ -67,7 +68,7 @@ export const useGridCellEditing = (apiRef, props) => {
67
68
  const handleCellKeyDown = React.useCallback((params, event) => {
68
69
  if (params.cellMode === GridCellModes.Edit) {
69
70
  // Wait until IME is settled for Asian languages like Japanese and Chinese
70
- // TODO: `event.which` is deprecated but this is a temporary workaround
71
+ // TODO: to replace at one point. See https://github.com/mui/material-ui/pull/39713#discussion_r1381678957.
71
72
  if (event.which === 229) {
72
73
  return;
73
74
  }
@@ -249,24 +250,7 @@ export const useGridCellEditing = (apiRef, props) => {
249
250
  } = params;
250
251
  let newValue = apiRef.current.getCellValue(id, field);
251
252
  if (deleteValue) {
252
- const fieldType = apiRef.current.getColumn(field).type;
253
- switch (fieldType) {
254
- case 'boolean':
255
- newValue = false;
256
- break;
257
- case 'date':
258
- case 'dateTime':
259
- case 'number':
260
- newValue = undefined;
261
- break;
262
- case 'singleSelect':
263
- newValue = null;
264
- break;
265
- case 'string':
266
- default:
267
- newValue = '';
268
- break;
269
- }
253
+ newValue = getDefaultCellValue(apiRef.current.getColumn(field));
270
254
  } else if (initialValue) {
271
255
  newValue = initialValue;
272
256
  }
@@ -16,6 +16,7 @@ import { gridRowsDataRowIdToIdLookupSelector } from "../rows/gridRowsSelector.js
16
16
  import { deepClone } from "../../../utils/utils.js";
17
17
  import { GridRowEditStopReasons, GridRowEditStartReasons } from "../../../models/params/gridRowParams.js";
18
18
  import { GRID_ACTIONS_COLUMN_TYPE } from "../../../colDef/index.js";
19
+ import { getDefaultCellValue } from "./utils.js";
19
20
  export const useGridRowEditing = (apiRef, props) => {
20
21
  const [rowModesModel, setRowModesModel] = React.useState({});
21
22
  const rowModesModelRef = React.useRef(rowModesModel);
@@ -109,7 +110,7 @@ export const useGridRowEditing = (apiRef, props) => {
109
110
  const handleCellKeyDown = React.useCallback((params, event) => {
110
111
  if (params.cellMode === GridRowModes.Edit) {
111
112
  // Wait until IME is settled for Asian languages like Japanese and Chinese
112
- // TODO: `event.which` is deprecated but this is a temporary workaround
113
+ // TODO: to replace at one point. See https://github.com/mui/material-ui/pull/39713#discussion_r1381678957.
113
114
  if (event.which === 229) {
114
115
  return;
115
116
  }
@@ -319,7 +320,11 @@ export const useGridRowEditing = (apiRef, props) => {
319
320
  }
320
321
  let newValue = apiRef.current.getCellValue(id, field);
321
322
  if (fieldToFocus === field && (deleteValue || initialValue)) {
322
- newValue = deleteValue ? '' : initialValue;
323
+ if (deleteValue) {
324
+ newValue = getDefaultCellValue(apiRef.current.getColumn(field));
325
+ } else if (initialValue) {
326
+ newValue = initialValue;
327
+ }
323
328
  }
324
329
  acc[field] = {
325
330
  value: newValue,
@@ -0,0 +1,15 @@
1
+ export const getDefaultCellValue = colDef => {
2
+ switch (colDef.type) {
3
+ case 'boolean':
4
+ return false;
5
+ case 'date':
6
+ case 'dateTime':
7
+ case 'number':
8
+ return undefined;
9
+ case 'singleSelect':
10
+ return null;
11
+ case 'string':
12
+ default:
13
+ return '';
14
+ }
15
+ };
@@ -38,6 +38,7 @@ function buildPrintWindow(title) {
38
38
  * @requires useGridParamsApi (method)
39
39
  */
40
40
  export const useGridPrintExport = (apiRef, props) => {
41
+ const hasRootReference = apiRef.current.rootElementRef.current !== null;
41
42
  const logger = useGridLogger(apiRef, 'useGridPrintExport');
42
43
  const doc = React.useRef(null);
43
44
  const previousGridState = React.useRef(null);
@@ -46,7 +47,7 @@ export const useGridPrintExport = (apiRef, props) => {
46
47
  const previousVirtualizationState = React.useRef();
47
48
  React.useEffect(() => {
48
49
  doc.current = ownerDocument(apiRef.current.rootElementRef.current);
49
- }, [apiRef]);
50
+ }, [apiRef, hasRootReference]);
50
51
 
51
52
  // Returns a promise because updateColumns triggers state update and
52
53
  // the new state needs to be in place before the grid can be sized correctly
@@ -34,6 +34,7 @@ export const focusStateInitializer = state => _extends({}, state, {
34
34
  export const useGridFocus = (apiRef, props) => {
35
35
  const logger = useGridLogger(apiRef, 'useGridFocus');
36
36
  const lastClickedCell = React.useRef(null);
37
+ const hasRootReference = apiRef.current.rootElementRef.current !== null;
37
38
  const publishCellFocusOut = React.useCallback((cell, event) => {
38
39
  if (cell) {
39
40
  // The row might have been deleted
@@ -380,7 +381,7 @@ export const useGridFocus = (apiRef, props) => {
380
381
  return () => {
381
382
  doc.removeEventListener('mouseup', handleDocumentClick);
382
383
  };
383
- }, [apiRef, handleDocumentClick]);
384
+ }, [apiRef, hasRootReference, handleDocumentClick]);
384
385
  useGridApiEventHandler(apiRef, 'columnHeaderBlur', handleBlur);
385
386
  useGridApiEventHandler(apiRef, 'cellDoubleClick', handleCellDoubleClick);
386
387
  useGridApiEventHandler(apiRef, 'cellMouseDown', handleCellMouseDown);