@mui/x-data-grid 5.14.0 → 5.15.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 (290) hide show
  1. package/CHANGELOG.md +147 -5
  2. package/DataGrid/DataGrid.js +7 -1
  3. package/DataGrid/useDataGridProps.js +1 -0
  4. package/colDef/gridStringColDef.js +1 -1
  5. package/components/GridRow.js +5 -1
  6. package/components/base/GridOverlays.js +2 -2
  7. package/components/cell/GridEditInputCell.d.ts +2 -5
  8. package/components/cell/GridEditInputCell.js +13 -14
  9. package/components/cell/GridEditSingleSelectCell.d.ts +4 -0
  10. package/components/cell/GridEditSingleSelectCell.js +11 -4
  11. package/components/columnSelection/GridCellCheckboxRenderer.js +5 -0
  12. package/components/containers/GridRoot.js +4 -2
  13. package/components/toolbar/GridToolbarDensitySelector.js +13 -4
  14. package/components/toolbar/GridToolbarExportContainer.js +13 -2
  15. package/constants/envConstants.d.ts +1 -1
  16. package/constants/envConstants.js +2 -11
  17. package/constants/gridClasses.d.ts +16 -0
  18. package/constants/gridClasses.js +1 -1
  19. package/constants/localeTextConstants.js +1 -1
  20. package/hooks/features/dimensions/useGridDimensions.js +6 -1
  21. package/hooks/features/editRows/useGridCellEditing.new.d.ts +1 -1
  22. package/hooks/features/editRows/useGridCellEditing.new.js +26 -16
  23. package/hooks/features/editRows/useGridCellEditing.old.js +2 -2
  24. package/hooks/features/editRows/useGridEditing.new.d.ts +1 -1
  25. package/hooks/features/editRows/useGridEditing.new.js +4 -0
  26. package/hooks/features/editRows/useGridEditing.old.js +1 -1
  27. package/hooks/features/editRows/useGridRowEditing.new.d.ts +1 -1
  28. package/hooks/features/editRows/useGridRowEditing.new.js +16 -10
  29. package/hooks/features/export/utils.js +8 -1
  30. package/hooks/features/filter/gridFilterState.d.ts +12 -1
  31. package/hooks/features/filter/gridFilterUtils.d.ts +8 -5
  32. package/hooks/features/filter/gridFilterUtils.js +74 -43
  33. package/hooks/features/filter/useGridFilter.js +16 -3
  34. package/hooks/features/focus/useGridFocus.js +11 -6
  35. package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.d.ts +1 -1
  36. package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +42 -34
  37. package/hooks/features/pagination/useGridPageSize.js +3 -1
  38. package/hooks/features/rows/gridRowsSelector.d.ts +14 -0
  39. package/hooks/features/rows/gridRowsSelector.js +20 -1
  40. package/hooks/features/rows/gridRowsState.d.ts +8 -1
  41. package/hooks/features/rows/gridRowsUtils.d.ts +4 -0
  42. package/hooks/features/rows/gridRowsUtils.js +21 -3
  43. package/hooks/features/rows/index.d.ts +1 -1
  44. package/hooks/features/rows/index.js +1 -1
  45. package/hooks/features/rows/useGridRows.js +5 -2
  46. package/hooks/features/rows/useGridRowsMeta.js +19 -4
  47. package/hooks/features/rows/useGridRowsPreProcessors.js +2 -1
  48. package/hooks/features/scroll/useGridScroll.js +7 -2
  49. package/hooks/features/selection/useGridSelection.js +7 -3
  50. package/hooks/features/sorting/useGridSorting.js +8 -0
  51. package/hooks/features/statePersistence/gridStatePersistenceInterface.d.ts +3 -0
  52. package/hooks/features/virtualization/useGridVirtualScroller.d.ts +3 -1
  53. package/hooks/features/virtualization/useGridVirtualScroller.js +31 -16
  54. package/index.js +1 -1
  55. package/internals/index.d.ts +5 -1
  56. package/internals/index.js +4 -0
  57. package/legacy/DataGrid/DataGrid.js +7 -1
  58. package/legacy/DataGrid/useDataGridProps.js +1 -0
  59. package/legacy/colDef/gridStringColDef.js +1 -1
  60. package/legacy/components/GridRow.js +5 -1
  61. package/legacy/components/base/GridOverlays.js +2 -2
  62. package/legacy/components/cell/GridEditInputCell.js +13 -14
  63. package/legacy/components/cell/GridEditSingleSelectCell.js +11 -3
  64. package/legacy/components/columnSelection/GridCellCheckboxRenderer.js +5 -0
  65. package/legacy/components/containers/GridRoot.js +4 -2
  66. package/legacy/components/toolbar/GridToolbarDensitySelector.js +14 -5
  67. package/legacy/components/toolbar/GridToolbarExportContainer.js +15 -2
  68. package/legacy/constants/envConstants.js +2 -11
  69. package/legacy/constants/gridClasses.js +1 -1
  70. package/legacy/constants/localeTextConstants.js +1 -1
  71. package/legacy/hooks/features/dimensions/useGridDimensions.js +6 -1
  72. package/legacy/hooks/features/editRows/useGridCellEditing.new.js +27 -17
  73. package/legacy/hooks/features/editRows/useGridCellEditing.old.js +2 -2
  74. package/legacy/hooks/features/editRows/useGridEditing.new.js +4 -0
  75. package/legacy/hooks/features/editRows/useGridEditing.old.js +1 -1
  76. package/legacy/hooks/features/editRows/useGridRowEditing.new.js +16 -10
  77. package/legacy/hooks/features/export/utils.js +13 -1
  78. package/legacy/hooks/features/filter/gridFilterUtils.js +84 -55
  79. package/legacy/hooks/features/filter/useGridFilter.js +16 -3
  80. package/legacy/hooks/features/focus/useGridFocus.js +11 -6
  81. package/legacy/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +47 -34
  82. package/legacy/hooks/features/pagination/useGridPageSize.js +3 -1
  83. package/legacy/hooks/features/rows/gridRowsSelector.js +23 -0
  84. package/legacy/hooks/features/rows/gridRowsUtils.js +21 -3
  85. package/legacy/hooks/features/rows/index.js +1 -1
  86. package/legacy/hooks/features/rows/useGridRows.js +5 -2
  87. package/legacy/hooks/features/rows/useGridRowsMeta.js +19 -4
  88. package/legacy/hooks/features/rows/useGridRowsPreProcessors.js +2 -1
  89. package/legacy/hooks/features/scroll/useGridScroll.js +7 -2
  90. package/legacy/hooks/features/selection/useGridSelection.js +7 -3
  91. package/legacy/hooks/features/sorting/useGridSorting.js +8 -0
  92. package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +32 -16
  93. package/legacy/index.js +1 -1
  94. package/legacy/internals/index.js +4 -0
  95. package/legacy/locales/arSD.js +1 -1
  96. package/legacy/locales/bgBG.js +1 -1
  97. package/legacy/locales/csCZ.js +1 -1
  98. package/legacy/locales/daDK.js +1 -1
  99. package/legacy/locales/deDE.js +9 -9
  100. package/legacy/locales/elGR.js +1 -1
  101. package/legacy/locales/esES.js +1 -1
  102. package/legacy/locales/faIR.js +1 -1
  103. package/legacy/locales/fiFI.js +1 -1
  104. package/legacy/locales/frFR.js +1 -1
  105. package/legacy/locales/heIL.js +1 -1
  106. package/legacy/locales/huHU.js +1 -1
  107. package/legacy/locales/itIT.js +15 -15
  108. package/legacy/locales/jaJP.js +3 -3
  109. package/legacy/locales/koKR.js +34 -30
  110. package/legacy/locales/nbNO.js +1 -1
  111. package/legacy/locales/nlNL.js +1 -1
  112. package/legacy/locales/plPL.js +1 -1
  113. package/legacy/locales/ptBR.js +1 -1
  114. package/legacy/locales/roRO.js +1 -1
  115. package/legacy/locales/ruRU.js +1 -1
  116. package/legacy/locales/skSK.js +1 -1
  117. package/legacy/locales/svSE.js +1 -1
  118. package/legacy/locales/trTR.js +1 -1
  119. package/legacy/locales/ukUA.js +1 -1
  120. package/legacy/locales/viVN.js +1 -1
  121. package/legacy/locales/zhCN.js +37 -33
  122. package/legacy/locales/zhTW.js +1 -1
  123. package/legacy/utils/keyboardUtils.js +8 -5
  124. package/locales/arSD.js +1 -1
  125. package/locales/bgBG.js +1 -1
  126. package/locales/csCZ.js +1 -1
  127. package/locales/daDK.js +1 -1
  128. package/locales/deDE.js +9 -9
  129. package/locales/elGR.js +1 -1
  130. package/locales/esES.js +1 -1
  131. package/locales/faIR.js +1 -1
  132. package/locales/fiFI.js +1 -1
  133. package/locales/frFR.js +1 -1
  134. package/locales/heIL.js +1 -1
  135. package/locales/huHU.js +1 -1
  136. package/locales/itIT.js +15 -15
  137. package/locales/jaJP.js +3 -3
  138. package/locales/koKR.js +30 -30
  139. package/locales/nbNO.js +1 -1
  140. package/locales/nlNL.js +1 -1
  141. package/locales/plPL.js +1 -1
  142. package/locales/ptBR.js +1 -1
  143. package/locales/roRO.js +1 -1
  144. package/locales/ruRU.js +1 -1
  145. package/locales/skSK.js +1 -1
  146. package/locales/svSE.js +1 -1
  147. package/locales/trTR.js +1 -1
  148. package/locales/ukUA.js +1 -1
  149. package/locales/viVN.js +1 -1
  150. package/locales/zhCN.js +33 -33
  151. package/locales/zhTW.js +1 -1
  152. package/models/gridRows.d.ts +5 -0
  153. package/models/props/DataGridProps.d.ts +8 -3
  154. package/modern/DataGrid/DataGrid.js +7 -1
  155. package/modern/DataGrid/useDataGridProps.js +1 -0
  156. package/modern/colDef/gridStringColDef.js +1 -1
  157. package/modern/components/GridRow.js +5 -1
  158. package/modern/components/base/GridOverlays.js +2 -2
  159. package/modern/components/cell/GridEditInputCell.js +13 -14
  160. package/modern/components/cell/GridEditSingleSelectCell.js +11 -4
  161. package/modern/components/columnSelection/GridCellCheckboxRenderer.js +5 -0
  162. package/modern/components/containers/GridRoot.js +4 -2
  163. package/modern/components/toolbar/GridToolbarDensitySelector.js +11 -4
  164. package/modern/components/toolbar/GridToolbarExportContainer.js +11 -2
  165. package/modern/constants/envConstants.js +2 -11
  166. package/modern/constants/gridClasses.js +1 -1
  167. package/modern/constants/localeTextConstants.js +1 -1
  168. package/modern/hooks/features/dimensions/useGridDimensions.js +6 -1
  169. package/modern/hooks/features/editRows/useGridCellEditing.new.js +24 -16
  170. package/modern/hooks/features/editRows/useGridCellEditing.old.js +2 -2
  171. package/modern/hooks/features/editRows/useGridEditing.new.js +4 -0
  172. package/modern/hooks/features/editRows/useGridEditing.old.js +1 -1
  173. package/modern/hooks/features/editRows/useGridRowEditing.new.js +16 -10
  174. package/modern/hooks/features/export/utils.js +6 -1
  175. package/modern/hooks/features/filter/gridFilterUtils.js +73 -42
  176. package/modern/hooks/features/filter/useGridFilter.js +16 -3
  177. package/modern/hooks/features/focus/useGridFocus.js +11 -6
  178. package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +42 -30
  179. package/modern/hooks/features/pagination/useGridPageSize.js +3 -1
  180. package/modern/hooks/features/rows/gridRowsSelector.js +18 -1
  181. package/modern/hooks/features/rows/gridRowsUtils.js +19 -3
  182. package/modern/hooks/features/rows/index.js +1 -1
  183. package/modern/hooks/features/rows/useGridRows.js +5 -2
  184. package/modern/hooks/features/rows/useGridRowsMeta.js +17 -4
  185. package/modern/hooks/features/rows/useGridRowsPreProcessors.js +2 -1
  186. package/modern/hooks/features/scroll/useGridScroll.js +5 -2
  187. package/modern/hooks/features/selection/useGridSelection.js +7 -1
  188. package/modern/hooks/features/sorting/useGridSorting.js +8 -0
  189. package/modern/hooks/features/virtualization/useGridVirtualScroller.js +30 -15
  190. package/modern/index.js +1 -1
  191. package/modern/internals/index.js +4 -0
  192. package/modern/locales/arSD.js +1 -1
  193. package/modern/locales/bgBG.js +1 -1
  194. package/modern/locales/csCZ.js +1 -1
  195. package/modern/locales/daDK.js +1 -1
  196. package/modern/locales/deDE.js +9 -9
  197. package/modern/locales/elGR.js +1 -1
  198. package/modern/locales/esES.js +1 -1
  199. package/modern/locales/faIR.js +1 -1
  200. package/modern/locales/fiFI.js +1 -1
  201. package/modern/locales/frFR.js +1 -1
  202. package/modern/locales/heIL.js +1 -1
  203. package/modern/locales/huHU.js +1 -1
  204. package/modern/locales/itIT.js +15 -15
  205. package/modern/locales/jaJP.js +3 -3
  206. package/modern/locales/koKR.js +30 -30
  207. package/modern/locales/nbNO.js +1 -1
  208. package/modern/locales/nlNL.js +1 -1
  209. package/modern/locales/plPL.js +1 -1
  210. package/modern/locales/ptBR.js +1 -1
  211. package/modern/locales/roRO.js +1 -1
  212. package/modern/locales/ruRU.js +1 -1
  213. package/modern/locales/skSK.js +1 -1
  214. package/modern/locales/svSE.js +1 -1
  215. package/modern/locales/trTR.js +1 -1
  216. package/modern/locales/ukUA.js +1 -1
  217. package/modern/locales/viVN.js +1 -1
  218. package/modern/locales/zhCN.js +33 -33
  219. package/modern/locales/zhTW.js +1 -1
  220. package/modern/utils/keyboardUtils.js +7 -2
  221. package/node/DataGrid/DataGrid.js +7 -1
  222. package/node/DataGrid/useDataGridProps.js +1 -0
  223. package/node/colDef/gridStringColDef.js +1 -1
  224. package/node/components/GridRow.js +5 -1
  225. package/node/components/base/GridOverlays.js +2 -2
  226. package/node/components/cell/GridEditInputCell.js +15 -16
  227. package/node/components/cell/GridEditSingleSelectCell.js +10 -4
  228. package/node/components/columnSelection/GridCellCheckboxRenderer.js +5 -0
  229. package/node/components/containers/GridRoot.js +3 -1
  230. package/node/components/toolbar/GridToolbarDensitySelector.js +13 -4
  231. package/node/components/toolbar/GridToolbarExportContainer.js +13 -2
  232. package/node/constants/envConstants.js +2 -13
  233. package/node/constants/gridClasses.js +1 -1
  234. package/node/constants/localeTextConstants.js +1 -1
  235. package/node/hooks/features/dimensions/useGridDimensions.js +7 -1
  236. package/node/hooks/features/editRows/useGridCellEditing.new.js +26 -16
  237. package/node/hooks/features/editRows/useGridCellEditing.old.js +2 -2
  238. package/node/hooks/features/editRows/useGridEditing.new.js +4 -0
  239. package/node/hooks/features/editRows/useGridEditing.old.js +1 -1
  240. package/node/hooks/features/editRows/useGridRowEditing.new.js +16 -10
  241. package/node/hooks/features/export/utils.js +7 -0
  242. package/node/hooks/features/filter/gridFilterUtils.js +81 -47
  243. package/node/hooks/features/filter/useGridFilter.js +15 -2
  244. package/node/hooks/features/focus/useGridFocus.js +11 -6
  245. package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +43 -34
  246. package/node/hooks/features/pagination/useGridPageSize.js +4 -1
  247. package/node/hooks/features/rows/gridRowsSelector.js +24 -2
  248. package/node/hooks/features/rows/gridRowsUtils.js +23 -2
  249. package/node/hooks/features/rows/index.js +70 -12
  250. package/node/hooks/features/rows/useGridRows.js +5 -2
  251. package/node/hooks/features/rows/useGridRowsMeta.js +20 -4
  252. package/node/hooks/features/rows/useGridRowsPreProcessors.js +2 -1
  253. package/node/hooks/features/scroll/useGridScroll.js +7 -1
  254. package/node/hooks/features/selection/useGridSelection.js +7 -3
  255. package/node/hooks/features/sorting/useGridSorting.js +8 -0
  256. package/node/hooks/features/virtualization/useGridVirtualScroller.js +31 -16
  257. package/node/index.js +1 -1
  258. package/node/internals/index.js +36 -0
  259. package/node/locales/arSD.js +1 -1
  260. package/node/locales/bgBG.js +1 -1
  261. package/node/locales/csCZ.js +1 -1
  262. package/node/locales/daDK.js +1 -1
  263. package/node/locales/deDE.js +9 -9
  264. package/node/locales/elGR.js +1 -1
  265. package/node/locales/esES.js +1 -1
  266. package/node/locales/faIR.js +1 -1
  267. package/node/locales/fiFI.js +1 -1
  268. package/node/locales/frFR.js +1 -1
  269. package/node/locales/heIL.js +1 -1
  270. package/node/locales/huHU.js +1 -1
  271. package/node/locales/itIT.js +15 -15
  272. package/node/locales/jaJP.js +3 -3
  273. package/node/locales/koKR.js +30 -30
  274. package/node/locales/nbNO.js +1 -1
  275. package/node/locales/nlNL.js +1 -1
  276. package/node/locales/plPL.js +1 -1
  277. package/node/locales/ptBR.js +1 -1
  278. package/node/locales/roRO.js +1 -1
  279. package/node/locales/ruRU.js +1 -1
  280. package/node/locales/skSK.js +1 -1
  281. package/node/locales/svSE.js +1 -1
  282. package/node/locales/trTR.js +1 -1
  283. package/node/locales/ukUA.js +1 -1
  284. package/node/locales/viVN.js +1 -1
  285. package/node/locales/zhCN.js +33 -33
  286. package/node/locales/zhTW.js +1 -1
  287. package/node/utils/keyboardUtils.js +10 -4
  288. package/package.json +1 -1
  289. package/utils/keyboardUtils.d.ts +2 -2
  290. package/utils/keyboardUtils.js +7 -2
@@ -23,6 +23,7 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
23
23
  cellModesModel = _React$useState2[0],
24
24
  setCellModesModel = _React$useState2[1];
25
25
 
26
+ var cellModesModelRef = React.useRef(cellModesModel);
26
27
  var prevCellModesModel = React.useRef({});
27
28
  var processRowUpdate = props.processRowUpdate,
28
29
  onProcessRowUpdateError = props.onProcessRowUpdateError,
@@ -70,6 +71,10 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
70
71
  return;
71
72
  }
72
73
 
74
+ if (apiRef.current.getCellMode(params.id, params.field) === GridCellModes.View) {
75
+ return;
76
+ }
77
+
73
78
  var newParams = _extends({}, params, {
74
79
  reason: GridCellEditStopReasons.cellFocusOut
75
80
  });
@@ -105,15 +110,14 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
105
110
  } else if (params.isEditable) {
106
111
  var _reason;
107
112
 
108
- if (isPrintableKey(event.key)) {
109
- if (event.ctrlKey && event.key !== 'v' || event.metaKey && event.key !== 'v' || event.altKey) {
110
- return;
111
- }
112
-
113
+ if (isPrintableKey(event)) {
114
+ _reason = GridCellEditStartReasons.printableKeyDown;
115
+ } else if ((event.ctrlKey || event.metaKey) && event.key === 'v') {
113
116
  _reason = GridCellEditStartReasons.printableKeyDown;
114
117
  } else if (event.key === 'Enter') {
115
118
  _reason = GridCellEditStartReasons.enterKeyDown;
116
- } else if (event.key === 'Delete') {
119
+ } else if (event.key === 'Delete' || event.key === 'Backspace') {
120
+ // Delete on Windows, Backspace on macOS
117
121
  _reason = GridCellEditStartReasons.deleteKeyDown;
118
122
  }
119
123
 
@@ -145,6 +149,7 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
145
149
  var id = params.id,
146
150
  field = params.field,
147
151
  reason = params.reason;
152
+ apiRef.current.unstable_runPendingEditCellValueMutation(id, field);
148
153
  var cellToFocusAfter;
149
154
 
150
155
  if (reason === GridCellEditStopReasons.enterKeyDown) {
@@ -158,7 +163,7 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
158
163
  var ignoreModifications = reason === 'escapeKeyDown';
159
164
  var editingState = gridEditRowsStateSelector(apiRef.current.state);
160
165
 
161
- if (editingState[id][field].isProcessingProps) {
166
+ if (editingState[id][field].isProcessingProps && !props.disableIgnoreModificationsIfProcessingProps) {
162
167
  // The user wants to stop editing the cell but we can't wait for the props to be processed.
163
168
  // In this case, discard the modifications.
164
169
  ignoreModifications = true;
@@ -170,7 +175,7 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
170
175
  ignoreModifications: ignoreModifications,
171
176
  cellToFocusAfter: cellToFocusAfter
172
177
  });
173
- }, [apiRef]);
178
+ }, [apiRef, props.disableIgnoreModificationsIfProcessingProps]);
174
179
  useGridApiEventHandler(apiRef, 'cellDoubleClick', runIfEditModeIsCell(handleCellDoubleClick));
175
180
  useGridApiEventHandler(apiRef, 'cellFocusOut', runIfEditModeIsCell(handleCellFocusOut));
176
181
  useGridApiEventHandler(apiRef, 'cellKeyDown', runIfEditModeIsCell(handleCellKeyDown));
@@ -198,17 +203,20 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
198
203
  }
199
204
 
200
205
  setCellModesModel(newModel);
206
+ cellModesModelRef.current = newModel;
201
207
  apiRef.current.publishEvent('cellModesModelChange', newModel);
202
208
  }, [apiRef, onCellModesModelChange, props.cellModesModel, signature]);
203
209
  var updateFieldInCellModesModel = React.useCallback(function (id, field, newProps) {
204
- var newModel = _extends({}, cellModesModel);
210
+ // We use the ref because it always contain the up-to-date value, different from the state
211
+ // that needs a rerender to reflect the new value
212
+ var newModel = _extends({}, cellModesModelRef.current);
205
213
 
206
214
  if (newProps !== null) {
207
215
  newModel[id] = _extends({}, newModel[id], _defineProperty({}, field, _extends({}, newProps)));
208
216
  } else {
209
- var _cellModesModel$id = cellModesModel[id],
210
- fieldToRemove = _cellModesModel$id[field],
211
- otherFields = _objectWithoutProperties(_cellModesModel$id, [field].map(_toPropertyKey)); // Ensure that we have a new object, not a reference
217
+ var _newModel$id = newModel[id],
218
+ fieldToRemove = _newModel$id[field],
219
+ otherFields = _objectWithoutProperties(_newModel$id, [field].map(_toPropertyKey)); // Ensure that we have a new object, not a reference
212
220
 
213
221
 
214
222
  newModel[id] = otherFields;
@@ -219,7 +227,7 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
219
227
  }
220
228
 
221
229
  updateCellModesModel(newModel);
222
- }, [cellModesModel, updateCellModesModel]);
230
+ }, [updateCellModesModel]);
223
231
  var updateOrDeleteFieldState = React.useCallback(function (id, field, newProps) {
224
232
  apiRef.current.setState(function (state) {
225
233
  var newEditingState = _extends({}, state.editRows);
@@ -286,12 +294,12 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
286
294
  apiRef.current.unstable_runPendingEditCellValueMutation(id, field);
287
295
 
288
296
  finishCellEditMode = function finishCellEditMode() {
297
+ updateOrDeleteFieldState(id, field, null);
298
+ updateFieldInCellModesModel(id, field, null);
299
+
289
300
  if (cellToFocusAfter !== 'none') {
290
301
  apiRef.current.unstable_moveFocusToRelativeCell(id, field, cellToFocusAfter);
291
302
  }
292
-
293
- updateOrDeleteFieldState(id, field, null);
294
- updateFieldInCellModesModel(id, field, null);
295
303
  };
296
304
 
297
305
  if (!ignoreModifications) {
@@ -358,6 +366,8 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
358
366
  }(), [apiRef, onProcessRowUpdateError, processRowUpdate, throwIfNotInMode, updateFieldInCellModesModel, updateOrDeleteFieldState]);
359
367
  var setCellEditingEditCellValue = React.useCallback( /*#__PURE__*/function () {
360
368
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(params) {
369
+ var _editingState$id, _editingState$id$fiel2;
370
+
361
371
  var id, field, value, column, row, parsedValue, editingState, newProps, hasChanged;
362
372
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
363
373
  while (1) {
@@ -419,7 +429,7 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
419
429
  newProps.value = column.preProcessEditCellProps ? editingState[id][field].value : parsedValue;
420
430
  updateOrDeleteFieldState(id, field, newProps);
421
431
  editingState = gridEditRowsStateSelector(apiRef.current.state);
422
- return _context2.abrupt("return", !editingState[id][field].error);
432
+ return _context2.abrupt("return", !((_editingState$id = editingState[id]) != null && (_editingState$id$fiel2 = _editingState$id[field]) != null && _editingState$id$fiel2.error));
423
433
 
424
434
  case 24:
425
435
  case "end":
@@ -210,7 +210,7 @@ export var useCellEditing = function useCellEditing(apiRef, props) {
210
210
  isEditMode = cellMode === GridCellModes.Edit;
211
211
  isModifierKeyPressed = event.ctrlKey || event.metaKey || event.altKey;
212
212
 
213
- if (!isEditMode && isCellEnterEditModeKeys(event.key) && !isModifierKeyPressed && !(event.key === ' ' && event.shiftKey)) {
213
+ if (!isEditMode && isCellEnterEditModeKeys(event) && !isModifierKeyPressed && !(event.key === ' ' && event.shiftKey)) {
214
214
  apiRef.current.publishEvent('cellEditStart', params, event);
215
215
  }
216
216
 
@@ -327,7 +327,7 @@ export var useCellEditing = function useCellEditing(apiRef, props) {
327
327
 
328
328
  apiRef.current.setCellMode(params.id, params.field, GridCellModes.Edit);
329
329
 
330
- if (isKeyboardEvent(event) && isPrintableKey(event.key)) {
330
+ if (isKeyboardEvent(event) && isPrintableKey(event)) {
331
331
  apiRef.current.unstable_setEditCellProps({
332
332
  id: params.id,
333
333
  field: params.field,
@@ -34,6 +34,10 @@ export var useGridEditing = function useGridEditing(apiRef, props) {
34
34
  return isCellEditableProp(params);
35
35
  }
36
36
 
37
+ if (params.rowNode.isPinned) {
38
+ return false;
39
+ }
40
+
37
41
  return true;
38
42
  }, [isCellEditableProp]);
39
43
 
@@ -34,7 +34,7 @@ export function useGridEditing(apiRef, props) {
34
34
  changeEvent: 'editRowsModelChange'
35
35
  });
36
36
  var isCellEditable = React.useCallback(function (params) {
37
- return !params.rowNode.isAutoGenerated && !!params.colDef.editable && !!params.colDef.renderEditCell && (!props.isCellEditable || props.isCellEditable(params));
37
+ return !params.rowNode.isAutoGenerated && !params.rowNode.isPinned && !!params.colDef.editable && !!params.colDef.renderEditCell && (!props.isCellEditable || props.isCellEditable(params));
38
38
  }, // eslint-disable-next-line react-hooks/exhaustive-deps
39
39
  [props.isCellEditable]);
40
40
 
@@ -22,6 +22,7 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
22
22
  rowModesModel = _React$useState2[0],
23
23
  setRowModesModel = _React$useState2[1];
24
24
 
25
+ var rowModesModelRef = React.useRef(rowModesModel);
25
26
  var prevRowModesModel = React.useRef({});
26
27
  var focusTimeout = React.useRef(null);
27
28
  var nextFocusedCell = React.useRef(null);
@@ -96,6 +97,11 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
96
97
  // The row might have been deleted during the click
97
98
  if (!apiRef.current.getRow(params.id)) {
98
99
  return;
100
+ } // The row may already changed its mode
101
+
102
+
103
+ if (apiRef.current.getRowMode(params.id) === GridRowModes.View) {
104
+ return;
99
105
  }
100
106
 
101
107
  var rowParams = apiRef.current.getRowParams(params.id);
@@ -161,15 +167,14 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
161
167
  } else if (params.isEditable) {
162
168
  var _reason;
163
169
 
164
- if (isPrintableKey(event.key)) {
165
- if (event.ctrlKey && event.key !== 'v' || event.metaKey && event.key !== 'v' || event.altKey) {
166
- return;
167
- }
168
-
170
+ if (isPrintableKey(event)) {
171
+ _reason = GridRowEditStartReasons.printableKeyDown;
172
+ } else if ((event.ctrlKey || event.metaKey) && event.key === 'v') {
169
173
  _reason = GridRowEditStartReasons.printableKeyDown;
170
174
  } else if (event.key === 'Enter') {
171
175
  _reason = GridRowEditStartReasons.enterKeyDown;
172
- } else if (event.key === 'Delete') {
176
+ } else if (event.key === 'Delete' || event.key === 'Backspace') {
177
+ // Delete on Windows, Backspace on macOS
173
178
  _reason = GridRowEditStartReasons.deleteKeyDown;
174
179
  }
175
180
 
@@ -218,7 +223,7 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
218
223
  var ignoreModifications = reason === 'escapeKeyDown';
219
224
  var editingState = gridEditRowsStateSelector(apiRef.current.state);
220
225
 
221
- if (!ignoreModifications) {
226
+ if (!ignoreModifications && !props.disableIgnoreModificationsIfProcessingProps) {
222
227
  // The user wants to stop editing the cell but we can't wait for the props to be processed.
223
228
  // In this case, discard the modifications if any field is processing its props.
224
229
  ignoreModifications = Object.values(editingState[id]).some(function (fieldProps) {
@@ -232,7 +237,7 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
232
237
  field: field,
233
238
  cellToFocusAfter: cellToFocusAfter
234
239
  });
235
- }, [apiRef]);
240
+ }, [apiRef, props.disableIgnoreModificationsIfProcessingProps]);
236
241
  useGridApiEventHandler(apiRef, 'cellDoubleClick', runIfEditModeIsRow(handleCellDoubleClick));
237
242
  useGridApiEventHandler(apiRef, 'cellFocusIn', runIfEditModeIsRow(handleCellFocusIn));
238
243
  useGridApiEventHandler(apiRef, 'cellFocusOut', runIfEditModeIsRow(handleCellFocusOut));
@@ -265,10 +270,11 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
265
270
  }
266
271
 
267
272
  setRowModesModel(newModel);
273
+ rowModesModelRef.current = newModel;
268
274
  apiRef.current.publishEvent('rowModesModelChange', newModel);
269
275
  }, [apiRef, onRowModesModelChange, props.rowModesModel, signature]);
270
276
  var updateRowInRowModesModel = React.useCallback(function (id, newProps) {
271
- var newModel = _extends({}, rowModesModel);
277
+ var newModel = _extends({}, rowModesModelRef.current);
272
278
 
273
279
  if (newProps !== null) {
274
280
  newModel[id] = _extends({}, newProps);
@@ -277,7 +283,7 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
277
283
  }
278
284
 
279
285
  updateRowModesModel(newModel);
280
- }, [rowModesModel, updateRowModesModel]);
286
+ }, [updateRowModesModel]);
281
287
  var updateOrDeleteRowState = React.useCallback(function (id, newProps) {
282
288
  apiRef.current.setState(function (state) {
283
289
  var newEditingState = _extends({}, state.editRows);
@@ -1,6 +1,7 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
1
2
  import { gridColumnDefinitionsSelector, gridVisibleColumnDefinitionsSelector } from '../columns';
2
3
  import { gridFilteredSortedRowIdsSelector } from '../filter';
3
- import { gridRowTreeSelector } from '../rows/gridRowsSelector';
4
+ import { gridPinnedRowsSelector, gridRowTreeSelector } from '../rows/gridRowsSelector';
4
5
  export var getColumnsToExport = function getColumnsToExport(_ref) {
5
6
  var apiRef = _ref.apiRef,
6
7
  options = _ref.options;
@@ -22,6 +23,8 @@ export var getColumnsToExport = function getColumnsToExport(_ref) {
22
23
  });
23
24
  };
24
25
  export var defaultGetRowsToExport = function defaultGetRowsToExport(_ref2) {
26
+ var _pinnedRows$top, _pinnedRows$bottom;
27
+
25
28
  var apiRef = _ref2.apiRef;
26
29
  var filteredSortedRowIds = gridFilteredSortedRowIdsSelector(apiRef);
27
30
  var rowTree = gridRowTreeSelector(apiRef);
@@ -31,6 +34,15 @@ export var defaultGetRowsToExport = function defaultGetRowsToExport(_ref2) {
31
34
 
32
35
  return ((_rowTree$id$position = rowTree[id].position) != null ? _rowTree$id$position : 'body') === 'body';
33
36
  });
37
+ var pinnedRows = gridPinnedRowsSelector(apiRef);
38
+ var topPinnedRowsIds = (pinnedRows == null ? void 0 : (_pinnedRows$top = pinnedRows.top) == null ? void 0 : _pinnedRows$top.map(function (row) {
39
+ return row.id;
40
+ })) || [];
41
+ var bottomPinnedRowsIds = (pinnedRows == null ? void 0 : (_pinnedRows$bottom = pinnedRows.bottom) == null ? void 0 : _pinnedRows$bottom.map(function (row) {
42
+ return row.id;
43
+ })) || [];
44
+ bodyRows.unshift.apply(bodyRows, _toConsumableArray(topPinnedRowsIds));
45
+ bodyRows.push.apply(bodyRows, _toConsumableArray(bottomPinnedRowsIds));
34
46
 
35
47
  if (selectedRows.size > 0) {
36
48
  return bodyRows.filter(function (id) {
@@ -1,8 +1,8 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import { GridLinkOperator } from '../../../models';
3
+ import { getDefaultGridFilterModel } from './gridFilterState';
3
4
  import { buildWarning } from '../../../utils/warning';
4
5
  import { gridColumnFieldsSelector, gridColumnLookupSelector } from '../columns';
5
- import { gridRowTreeSelector } from '../rows/gridRowsSelector';
6
6
 
7
7
  /**
8
8
  * Adds default values to the optional fields of a filter items.
@@ -87,10 +87,7 @@ export var mergeStateWithFilterModel = function mergeStateWithFilterModel(filter
87
87
  */
88
88
 
89
89
  export var buildAggregatedFilterItemsApplier = function buildAggregatedFilterItemsApplier(filterModel, apiRef) {
90
- var items = filterModel.items,
91
- _filterModel$linkOper = filterModel.linkOperator,
92
- linkOperator = _filterModel$linkOper === void 0 ? GridLinkOperator.And : _filterModel$linkOper;
93
- var tree = gridRowTreeSelector(apiRef);
90
+ var items = filterModel.items;
94
91
 
95
92
  var getFilterCallbackFromItem = function getFilterCallbackFromItem(filterItem) {
96
93
  if (!filterItem.columnField || !filterItem.operatorValue) {
@@ -160,24 +157,14 @@ export var buildAggregatedFilterItemsApplier = function buildAggregatedFilterIte
160
157
  }
161
158
 
162
159
  return function (rowId, shouldApplyFilter) {
163
- if (tree[rowId].position === 'footer') {
164
- return true;
165
- }
166
-
160
+ var resultPerItemId = {};
167
161
  var filteredAppliers = shouldApplyFilter ? appliers.filter(function (applier) {
168
162
  return shouldApplyFilter(applier.item.columnField);
169
- }) : appliers; // Return `false` as soon as we have a failing filter
170
-
171
- if (linkOperator === GridLinkOperator.And) {
172
- return filteredAppliers.every(function (applier) {
173
- return applier.fn(rowId);
174
- });
175
- } // Return `true` as soon as we have a passing filter
176
-
177
-
178
- return filteredAppliers.some(function (applier) {
179
- return applier.fn(rowId);
163
+ }) : appliers;
164
+ filteredAppliers.forEach(function (applier) {
165
+ resultPerItemId[applier.item.id] = applier.fn(rowId);
180
166
  });
167
+ return resultPerItemId;
181
168
  };
182
169
  };
183
170
  /**
@@ -189,9 +176,7 @@ export var buildAggregatedFilterItemsApplier = function buildAggregatedFilterIte
189
176
 
190
177
  export var buildAggregatedQuickFilterApplier = function buildAggregatedQuickFilterApplier(filterModel, apiRef) {
191
178
  var _filterModel$quickFil = filterModel.quickFilterValues,
192
- quickFilterValues = _filterModel$quickFil === void 0 ? [] : _filterModel$quickFil,
193
- _filterModel$quickFil2 = filterModel.quickFilterLogicOperator,
194
- quickFilterLogicOperator = _filterModel$quickFil2 === void 0 ? GridLinkOperator.And : _filterModel$quickFil2;
179
+ quickFilterValues = _filterModel$quickFil === void 0 ? [] : _filterModel$quickFil;
195
180
 
196
181
  if (quickFilterValues.length === 0) {
197
182
  return null;
@@ -217,6 +202,11 @@ export var buildAggregatedQuickFilterApplier = function buildAggregatedQuickFilt
217
202
  return appliersPerColumnField[field][index] != null;
218
203
  });
219
204
  });
205
+
206
+ if (sanitizedQuickFilterValues.length === 0) {
207
+ return null;
208
+ }
209
+
220
210
  return function (rowId, shouldApplyFilter) {
221
211
  var usedCellParams = {};
222
212
  var columnsFieldsToFilter = [];
@@ -225,53 +215,92 @@ export var buildAggregatedQuickFilterApplier = function buildAggregatedQuickFilt
225
215
  usedCellParams[columnField] = apiRef.current.getCellParams(rowId, columnField);
226
216
  columnsFieldsToFilter.push(columnField);
227
217
  }
228
- }); // Return `false` as soon as we have a quick filter value that does not match any column
229
-
230
- if (quickFilterLogicOperator === GridLinkOperator.And) {
231
- return sanitizedQuickFilterValues.every(function (value, index) {
232
- return columnsFieldsToFilter.some(function (field) {
233
- var _appliersPerColumnFie, _appliersPerColumnFie2;
234
-
235
- if (appliersPerColumnField[field][index] == null) {
236
- return false;
237
- }
238
-
239
- return (_appliersPerColumnFie = (_appliersPerColumnFie2 = appliersPerColumnField[field])[index]) == null ? void 0 : _appliersPerColumnFie.call(_appliersPerColumnFie2, usedCellParams[field]);
240
- });
241
- });
242
- } // Return `true` as soon as we have have a quick filter value that match any column
243
-
244
-
245
- return sanitizedQuickFilterValues.some(function (value, index) {
246
- return columnsFieldsToFilter.some(function (field) {
247
- var _appliersPerColumnFie3, _appliersPerColumnFie4;
218
+ });
219
+ var quickFilterValueResult = {};
220
+ sanitizedQuickFilterValues.forEach(function (value, index) {
221
+ var isPassing = columnsFieldsToFilter.some(function (field) {
222
+ var _appliersPerColumnFie, _appliersPerColumnFie2;
248
223
 
249
224
  if (appliersPerColumnField[field][index] == null) {
250
225
  return false;
251
226
  }
252
227
 
253
- return (_appliersPerColumnFie3 = (_appliersPerColumnFie4 = appliersPerColumnField[field])[index]) == null ? void 0 : _appliersPerColumnFie3.call(_appliersPerColumnFie4, usedCellParams[field]);
228
+ return (_appliersPerColumnFie = (_appliersPerColumnFie2 = appliersPerColumnField[field])[index]) == null ? void 0 : _appliersPerColumnFie.call(_appliersPerColumnFie2, usedCellParams[field]);
254
229
  });
230
+ quickFilterValueResult[value] = isPassing;
255
231
  });
232
+ return quickFilterValueResult;
256
233
  };
257
234
  };
258
235
  export var buildAggregatedFilterApplier = function buildAggregatedFilterApplier(filterModel, apiRef) {
259
236
  var isRowMatchingFilterItems = buildAggregatedFilterItemsApplier(filterModel, apiRef);
260
237
  var isRowMatchingQuickFilter = buildAggregatedQuickFilterApplier(filterModel, apiRef);
238
+ return function (rowId, shouldApplyFilter) {
239
+ return {
240
+ passingFilterItems: isRowMatchingFilterItems && isRowMatchingFilterItems(rowId, shouldApplyFilter),
241
+ passingQuickFilterValues: isRowMatchingQuickFilter && isRowMatchingQuickFilter(rowId, shouldApplyFilter)
242
+ };
243
+ };
244
+ };
245
+ export var passFilterLogic = function passFilterLogic(allFilterItemResults, allQuickFilterResults, filterModel) {
246
+ var _filterModel$quickFil2, _filterModel$linkOper;
261
247
 
262
- if (isRowMatchingFilterItems == null && isRowMatchingQuickFilter == null) {
263
- return null;
264
- }
248
+ var cleanedAllFilterItemResults = allFilterItemResults.filter(function (result) {
249
+ return result != null;
250
+ });
251
+ var cleanedAllQuickFilterResults = allQuickFilterResults.filter(function (result) {
252
+ return result != null;
253
+ }); // Defaultize operators
254
+
255
+ var quickFilterLogicOperator = (_filterModel$quickFil2 = filterModel.quickFilterLogicOperator) != null ? _filterModel$quickFil2 : getDefaultGridFilterModel().quickFilterLogicOperator;
256
+ var linkOperator = (_filterModel$linkOper = filterModel.linkOperator) != null ? _filterModel$linkOper : getDefaultGridFilterModel().linkOperator; // get result for filter items model
257
+
258
+ if (cleanedAllFilterItemResults.length > 0) {
259
+ // Return true if the item pass with one of the rows
260
+ var filterItemPredicate = function filterItemPredicate(item) {
261
+ return cleanedAllFilterItemResults.some(function (filterItemResult) {
262
+ return filterItemResult[item.id];
263
+ });
264
+ };
265
+
266
+ if (linkOperator === GridLinkOperator.And) {
267
+ var passesAllFilters = filterModel.items.every(filterItemPredicate);
268
+
269
+ if (!passesAllFilters) {
270
+ return false;
271
+ }
272
+ } else {
273
+ var passesSomeFilters = filterModel.items.some(filterItemPredicate);
274
+
275
+ if (!passesSomeFilters) {
276
+ return false;
277
+ }
278
+ }
279
+ } // get result for quick filter model
265
280
 
266
- if (isRowMatchingFilterItems == null) {
267
- return isRowMatchingQuickFilter;
268
- }
269
281
 
270
- if (isRowMatchingQuickFilter == null) {
271
- return isRowMatchingFilterItems;
282
+ if (cleanedAllQuickFilterResults.length > 0 && filterModel.quickFilterValues != null) {
283
+ // Return true if the item pass with one of the rows
284
+ var quickFilterValuePredicate = function quickFilterValuePredicate(value) {
285
+ return cleanedAllQuickFilterResults.some(function (quickFilterValueResult) {
286
+ return quickFilterValueResult[value];
287
+ });
288
+ };
289
+
290
+ if (quickFilterLogicOperator === GridLinkOperator.And) {
291
+ var passesAllQuickFilterValues = filterModel.quickFilterValues.every(quickFilterValuePredicate);
292
+
293
+ if (!passesAllQuickFilterValues) {
294
+ return false;
295
+ }
296
+ } else {
297
+ var passesSomeQuickFilterValues = filterModel.quickFilterValues.some(quickFilterValuePredicate);
298
+
299
+ if (!passesSomeQuickFilterValues) {
300
+ return false;
301
+ }
302
+ }
272
303
  }
273
304
 
274
- return function (rowId, shouldApplyFilter) {
275
- return isRowMatchingFilterItems(rowId, shouldApplyFilter) && isRowMatchingQuickFilter(rowId, shouldApplyFilter);
276
- };
305
+ return true;
277
306
  };
@@ -13,7 +13,7 @@ import { useFirstRender } from '../../utils/useFirstRender';
13
13
  import { gridRowIdsSelector } from '../rows';
14
14
  import { useGridRegisterPipeProcessor } from '../../core/pipeProcessing';
15
15
  import { GRID_DEFAULT_STRATEGY, useGridRegisterStrategyProcessor } from '../../core/strategyProcessing';
16
- import { buildAggregatedFilterApplier, sanitizeFilterModel, mergeStateWithFilterModel, cleanFilterItem } from './gridFilterUtils';
16
+ import { buildAggregatedFilterApplier, sanitizeFilterModel, mergeStateWithFilterModel, cleanFilterItem, passFilterLogic } from './gridFilterUtils';
17
17
  import { isDeepEqual } from '../../../utils/utils';
18
18
  import { jsx as _jsx } from "react/jsx-runtime";
19
19
  export var filterStateInitializer = function filterStateInitializer(state, props, apiRef) {
@@ -50,7 +50,8 @@ export var useGridFilter = function useGridFilter(apiRef, props) {
50
50
  var filterModel = gridFilterModelSelector(state, apiRef.current.instanceId);
51
51
  var isRowMatchingFilters = props.filterMode === GridFeatureModeConstant.client ? buildAggregatedFilterApplier(filterModel, apiRef) : null;
52
52
  var filteringResult = apiRef.current.unstable_applyStrategyProcessor('filtering', {
53
- isRowMatchingFilters: isRowMatchingFilters
53
+ isRowMatchingFilters: isRowMatchingFilters,
54
+ filterModel: filterModel != null ? filterModel : getDefaultGridFilterModel()
54
55
  });
55
56
  return _extends({}, state, {
56
57
  filter: _extends({}, state.filter, filteringResult)
@@ -278,7 +279,19 @@ export var useGridFilter = function useGridFilter(apiRef, props) {
278
279
 
279
280
  for (var i = 0; i < rowIds.length; i += 1) {
280
281
  var rowId = rowIds[i];
281
- filteredRowsLookup[rowId] = params.isRowMatchingFilters(rowId);
282
+ var isRowPassing = void 0;
283
+
284
+ if (typeof rowId === 'string' && rowId.startsWith('auto-generated-group-footer')) {
285
+ isRowPassing = true;
286
+ } else {
287
+ var _params$isRowMatching = params.isRowMatchingFilters(rowId),
288
+ passingFilterItems = _params$isRowMatching.passingFilterItems,
289
+ passingQuickFilterValues = _params$isRowMatching.passingQuickFilterValues;
290
+
291
+ isRowPassing = passFilterLogic([passingFilterItems], [passingQuickFilterValues], params.filterModel);
292
+ }
293
+
294
+ filteredRowsLookup[rowId] = isRowPassing;
282
295
  }
283
296
 
284
297
  return {
@@ -62,6 +62,12 @@ export var useGridFocus = function useGridFocus(apiRef, props) {
62
62
  return;
63
63
  }
64
64
 
65
+ if (focusedCell) {
66
+ // There's a focused cell but another cell was clicked
67
+ // Publishes an event to notify that the focus was lost
68
+ apiRef.current.publishEvent('cellFocusOut', apiRef.current.getCellParams(focusedCell.id, focusedCell.field));
69
+ }
70
+
65
71
  apiRef.current.publishEvent('cellFocusIn', apiRef.current.getCellParams(id, field));
66
72
  }, [apiRef, logger]);
67
73
  var setColumnHeaderFocus = React.useCallback(function (field) {
@@ -195,11 +201,7 @@ export var useGridFocus = function useGridFocus(apiRef, props) {
195
201
 
196
202
  if (!apiRef.current.getRow(focusedCell.id)) {
197
203
  return;
198
- } // There's a focused cell but another cell was clicked
199
- // Publishes an event to notify that the focus was lost
200
-
201
-
202
- apiRef.current.publishEvent('cellFocusOut', apiRef.current.getCellParams(focusedCell.id, focusedCell.field), event);
204
+ }
203
205
 
204
206
  if (cellParams) {
205
207
  apiRef.current.setCellFocus(cellParams.id, cellParams.field);
@@ -212,7 +214,10 @@ export var useGridFocus = function useGridFocus(apiRef, props) {
212
214
  }
213
215
  });
214
216
  });
215
- apiRef.current.forceUpdate();
217
+ apiRef.current.forceUpdate(); // There's a focused cell but another element (not a cell) was clicked
218
+ // Publishes an event to notify that the focus was lost
219
+
220
+ apiRef.current.publishEvent('cellFocusOut', apiRef.current.getCellParams(focusedCell.id, focusedCell.field), event);
216
221
  }
217
222
  }, [apiRef]);
218
223
  var handleCellModeChange = React.useCallback(function (params) {