@mui/x-data-grid 6.18.2 → 6.18.4

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 (75) hide show
  1. package/CHANGELOG.md +101 -1
  2. package/components/GridRow.js +2 -4
  3. package/components/cell/GridCell.js +15 -15
  4. package/components/cell/GridEditDateCell.js +1 -20
  5. package/components/columnHeaders/GridColumnGroupHeader.js +2 -1
  6. package/components/columnHeaders/GridColumnHeaderItem.js +2 -1
  7. package/components/panel/filterPanel/GridFilterForm.js +2 -2
  8. package/components/panel/filterPanel/GridFilterInputValue.js +1 -1
  9. package/hooks/features/editing/useGridCellEditing.js +8 -21
  10. package/hooks/features/editing/useGridRowEditing.js +7 -21
  11. package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -1
  12. package/hooks/features/rowSelection/useGridRowSelection.js +2 -1
  13. package/index.js +1 -1
  14. package/internals/index.d.ts +1 -1
  15. package/internals/index.js +1 -1
  16. package/legacy/components/GridRow.js +2 -4
  17. package/legacy/components/cell/GridCell.js +14 -14
  18. package/legacy/components/cell/GridEditDateCell.js +1 -20
  19. package/legacy/components/columnHeaders/GridColumnGroupHeader.js +2 -1
  20. package/legacy/components/columnHeaders/GridColumnHeaderItem.js +2 -1
  21. package/legacy/components/panel/filterPanel/GridFilterForm.js +2 -2
  22. package/legacy/components/panel/filterPanel/GridFilterInputValue.js +1 -1
  23. package/legacy/hooks/features/editing/useGridCellEditing.js +8 -21
  24. package/legacy/hooks/features/editing/useGridRowEditing.js +7 -23
  25. package/legacy/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -1
  26. package/legacy/hooks/features/rowSelection/useGridRowSelection.js +2 -1
  27. package/legacy/index.js +1 -1
  28. package/legacy/internals/index.js +1 -1
  29. package/legacy/locales/bgBG.js +33 -37
  30. package/legacy/locales/daDK.js +37 -39
  31. package/legacy/models/params/gridEditCellParams.js +1 -0
  32. package/legacy/utils/domUtils.js +10 -1
  33. package/locales/bgBG.js +33 -37
  34. package/locales/daDK.js +37 -39
  35. package/models/api/gridEditingApi.d.ts +2 -4
  36. package/models/params/gridEditCellParams.d.ts +3 -1
  37. package/models/params/gridEditCellParams.js +1 -0
  38. package/models/params/gridRowParams.d.ts +1 -0
  39. package/modern/components/GridRow.js +2 -4
  40. package/modern/components/cell/GridCell.js +15 -15
  41. package/modern/components/cell/GridEditDateCell.js +1 -20
  42. package/modern/components/columnHeaders/GridColumnGroupHeader.js +2 -1
  43. package/modern/components/columnHeaders/GridColumnHeaderItem.js +2 -1
  44. package/modern/components/panel/filterPanel/GridFilterForm.js +2 -2
  45. package/modern/components/panel/filterPanel/GridFilterInputValue.js +1 -1
  46. package/modern/hooks/features/editing/useGridCellEditing.js +8 -21
  47. package/modern/hooks/features/editing/useGridRowEditing.js +7 -21
  48. package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -1
  49. package/modern/hooks/features/rowSelection/useGridRowSelection.js +2 -1
  50. package/modern/index.js +1 -1
  51. package/modern/internals/index.js +1 -1
  52. package/modern/locales/bgBG.js +33 -37
  53. package/modern/locales/daDK.js +37 -39
  54. package/modern/models/params/gridEditCellParams.js +1 -0
  55. package/modern/utils/domUtils.js +10 -1
  56. package/node/components/GridRow.js +1 -3
  57. package/node/components/cell/GridCell.js +15 -15
  58. package/node/components/cell/GridEditDateCell.js +1 -20
  59. package/node/components/columnHeaders/GridColumnGroupHeader.js +2 -1
  60. package/node/components/columnHeaders/GridColumnHeaderItem.js +2 -1
  61. package/node/components/panel/filterPanel/GridFilterForm.js +2 -2
  62. package/node/components/panel/filterPanel/GridFilterInputValue.js +1 -1
  63. package/node/hooks/features/editing/useGridCellEditing.js +7 -20
  64. package/node/hooks/features/editing/useGridRowEditing.js +6 -20
  65. package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -1
  66. package/node/hooks/features/rowSelection/useGridRowSelection.js +2 -1
  67. package/node/index.js +1 -1
  68. package/node/internals/index.js +7 -0
  69. package/node/locales/bgBG.js +33 -37
  70. package/node/locales/daDK.js +37 -39
  71. package/node/models/params/gridEditCellParams.js +1 -0
  72. package/node/utils/domUtils.js +11 -1
  73. package/package.json +1 -1
  74. package/utils/domUtils.d.ts +2 -0
  75. package/utils/domUtils.js +10 -1
package/CHANGELOG.md CHANGED
@@ -3,6 +3,105 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 6.18.4
7
+
8
+ _Dec 8, 2023_
9
+
10
+ We'd like to offer a big thanks to the 6 contributors who made this release possible. Here are some highlights ✨:
11
+
12
+ - 📚 Add [Pickers FAQ page](https://mui.com/x/react-date-pickers/faq/)
13
+ - 🌍 Improve Danish (da-DK) locale on Data Grid
14
+ - 🐞 Bugfixes
15
+
16
+ ### Data Grid
17
+
18
+ #### `@mui/x-data-grid@6.18.4`
19
+
20
+ - [DataGrid] Fix cell slot style override (#11215) @oliviertassinari
21
+ - [l10n] Improve Danish (da-DK) locale (#11346) @goibon
22
+
23
+ #### `@mui/x-data-grid-pro@6.18.4` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
24
+
25
+ Same changes as in `@mui/x-data-grid@6.18.4`.
26
+
27
+ #### `@mui/x-data-grid-premium@6.18.4` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
28
+
29
+ Same changes as in `@mui/x-data-grid-pro@6.18.4`.
30
+
31
+ ### Date Pickers
32
+
33
+ #### `@mui/x-date-pickers@6.18.4`
34
+
35
+ - [pickers] Fix `MultiSectionDigitalClock` issues (#11308) @LukasTy
36
+
37
+ #### `@mui/x-date-pickers-pro@6.18.4` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
38
+
39
+ Same changes as in `@mui/x-date-pickers@6.18.4`.
40
+
41
+ ### Docs
42
+
43
+ - [docs] Fix typo (#11323) @cadam11
44
+ - [docs] Add FAQ page (#11347) @noraleonte
45
+
46
+ ## 6.18.3
47
+
48
+ _Dec 4, 2023_
49
+
50
+ We'd like to offer a big thanks to the 10 contributors who made this release possible. Here are some highlights ✨:
51
+
52
+ - 📈 Fix a lot of Charts package issues
53
+ - 🌍 Improve Bulgarian (bg-BG) locale on Data Grid
54
+ - 🐞 Bugfixes
55
+ - 📚 Documentation improvements
56
+
57
+ ### Data Grid
58
+
59
+ #### `@mui/x-data-grid@6.18.3`
60
+
61
+ - [DataGrid] Fix cell editing adding a leading "v" on paste (#11166) @prasad5795
62
+ - [DataGrid] Fix handling of event target in portal (#11209) @cherniavskii
63
+ - [DataGrid] Fix `onFilterModelChange` being fired with stale field value (#11244) @gitstart
64
+ - [l10n] Improve Bulgarian (bg-BG) locale (#10856) (#11206) @Kristiqn95
65
+
66
+ #### `@mui/x-data-grid-pro@6.18.3` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
67
+
68
+ Same changes as in `@mui/x-data-grid@6.18.3`.
69
+
70
+ #### `@mui/x-data-grid-premium@6.18.3` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
71
+
72
+ Same changes as in `@mui/x-data-grid-pro@6.18.3`, plus:
73
+
74
+ - [DataGridPremium] Fix aggregated column ignoring column definition changes (#11176) @cherniavskii
75
+ - [DataGridPremium] Fix custom filter operators not working on aggregated column (#11201) @cherniavskii
76
+
77
+ ### Date Pickers
78
+
79
+ #### `@mui/x-date-pickers@6.18.3`
80
+
81
+ - [pickers] Correctly format `MultiSectionDigitalClock` number sections (#11297) @LukasTy
82
+ - [pickers] Expand field placeholder methods flexibility by providing `format` parameter (#11254) @LukasTy
83
+
84
+ #### `@mui/x-date-pickers-pro@6.18.3` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
85
+
86
+ Same changes as in `@mui/x-date-pickers@6.18.3`.
87
+
88
+ ### Charts / `@mui/x-charts@6.18.3`
89
+
90
+ - [charts] Adjusted `defaultizeValueFormatter` util to accept an optional `series.valueFormatter` value (#11213) @michelengelen
91
+ - [charts] Apply `labelStyle` and `tickLabelStyle` props on `<ChartsYAxis />` (#11180) @akamfoad
92
+ - [charts] Fix TS config (#11259) @alexfauquette
93
+ - [charts] Fix error with empty dataset (#11063) @alexfauquette
94
+ - [charts] Fix export strategy (#11235) @alexfauquette
95
+
96
+ ### Docs
97
+
98
+ - [docs] Add LTS section to support page (#11300) @joserodolfofreitas
99
+ - [docs] Add end v6 blogpost to whats new page (#11299) @joserodolfofreitas
100
+ - [docs] Document charts composition (#10710) @alexfauquette
101
+ - [docs] Fix version links (#11167) @LukasTy
102
+ - [docs] Improve Data Grid togglable columns example (#11241) @MBilalShafi
103
+ - [docs] Split charts overview and getting started in distinct pages (#10910) @alexfauquette
104
+
6
105
  ## 6.18.2
7
106
 
8
107
  _Nov 23, 2023_
@@ -288,7 +387,7 @@ Same changes as in `@mui/x-date-pickers@6.16.3`, plus:
288
387
 
289
388
  - [charts] Add reference links to area + bar chart components (#10652) @michelengelen
290
389
  - [charts] Add reference links to line chart + sparkline components (#10650) @michelengelen
291
- - [charts] Add reference links to pie + scatter chart components (#10653) @michelengelen
390
+ - [charts] Add reference links to pie + scatter chart components (#10653) @michelengelen
292
391
  - [charts] Render only when `width` and `height` are resolved (#10714) @alexfauquette
293
392
  - [charts] Support animation on `BarChart` (#9926) @alexfauquette
294
393
  - [charts] Use new text component to avoid tick label overflow on x-axis (#10648) @alexfauquette
@@ -364,6 +463,7 @@ It adds line break support and avoids overlapping text in the legend.
364
463
  This comes with some breaking changes.
365
464
 
366
465
  - The DOM structure is modified. An intermediary `<tspan />` element has been added. This can impact how your style is applied.
466
+
367
467
  ```diff
368
468
  - <text>The label</text>
369
469
  + <text><tspan>The label</tspan></text>
@@ -13,7 +13,7 @@ import { useGridRootProps } from '../hooks/utils/useGridRootProps';
13
13
  import { gridColumnsTotalWidthSelector } from '../hooks/features/columns/gridColumnsSelector';
14
14
  import { useGridSelector, objectShallowCompare } from '../hooks/utils/useGridSelector';
15
15
  import { useGridVisibleRows } from '../hooks/utils/useGridVisibleRows';
16
- import { findParentElementFromClassName } from '../utils/domUtils';
16
+ import { findParentElementFromClassName, isEventTargetInPortal } from '../utils/domUtils';
17
17
  import { GRID_CHECKBOX_SELECTION_COL_DEF } from '../colDef/gridCheckboxSelectionColDef';
18
18
  import { GRID_ACTIONS_COLUMN_TYPE } from '../colDef/gridActionsColDef';
19
19
  import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from '../constants/gridDetailPanelToggleField';
@@ -137,9 +137,7 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
137
137
  }, [apiRef, currentPage.range, index, rowHeight, rowId, position]);
138
138
  const publish = React.useCallback((eventName, propHandler) => event => {
139
139
  // Ignore portal
140
- // The target is not an element when triggered by a Select inside the cell
141
- // See https://github.com/mui/material-ui/issues/10534
142
- if (event.target.nodeType === 1 && !event.currentTarget.contains(event.target)) {
140
+ if (isEventTargetInPortal(event)) {
143
141
  return;
144
142
  }
145
143
 
@@ -1,8 +1,8 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
3
  const _excluded = ["changeReason", "unstable_updateValueOnRender"],
4
- _excluded2 = ["align", "children", "editCellState", "colIndex", "column", "cellMode", "field", "formattedValue", "hasFocus", "height", "isEditable", "isSelected", "rowId", "tabIndex", "value", "width", "className", "showRightBorder", "extendRowFullWidth", "row", "colSpan", "disableDragEvents", "isNotVisible", "onClick", "onDoubleClick", "onMouseDown", "onMouseUp", "onMouseOver", "onKeyDown", "onKeyUp", "onDragEnter", "onDragOver"],
5
- _excluded3 = ["column", "rowId", "editCellState", "align", "children", "colIndex", "height", "width", "className", "showRightBorder", "extendRowFullWidth", "row", "colSpan", "disableDragEvents", "isNotVisible", "onClick", "onDoubleClick", "onMouseDown", "onMouseUp", "onMouseOver", "onKeyDown", "onKeyUp", "onDragEnter", "onDragOver"],
4
+ _excluded2 = ["align", "children", "editCellState", "colIndex", "column", "cellMode", "field", "formattedValue", "hasFocus", "height", "isEditable", "isSelected", "rowId", "tabIndex", "style", "value", "width", "className", "showRightBorder", "extendRowFullWidth", "row", "colSpan", "disableDragEvents", "isNotVisible", "onClick", "onDoubleClick", "onMouseDown", "onMouseUp", "onMouseOver", "onKeyDown", "onKeyUp", "onDragEnter", "onDragOver"],
5
+ _excluded3 = ["column", "rowId", "editCellState", "align", "children", "colIndex", "height", "width", "className", "showRightBorder", "extendRowFullWidth", "row", "colSpan", "disableDragEvents", "isNotVisible", "onClick", "onDoubleClick", "onMouseDown", "onMouseUp", "onMouseOver", "onKeyDown", "onKeyUp", "onDragEnter", "onDragOver", "style"],
6
6
  _excluded4 = ["changeReason", "unstable_updateValueOnRender"];
7
7
  import * as React from 'react';
8
8
  import PropTypes from 'prop-types';
@@ -171,6 +171,7 @@ const GridCell = /*#__PURE__*/React.forwardRef((props, ref) => {
171
171
  isSelected,
172
172
  rowId,
173
173
  tabIndex,
174
+ style: styleProp,
174
175
  value,
175
176
  width,
176
177
  className,
@@ -237,15 +238,14 @@ const GridCell = /*#__PURE__*/React.forwardRef((props, ref) => {
237
238
  border: 0
238
239
  };
239
240
  }
240
- const cellStyle = {
241
+ const cellStyle = _extends({
241
242
  minWidth: width,
242
243
  maxWidth: width,
243
244
  minHeight: height,
244
- maxHeight: height === 'auto' ? 'none' : height // max-height doesn't support "auto"
245
- };
246
-
245
+ maxHeight: height === 'auto' ? 'none' : height
246
+ }, styleProp);
247
247
  return cellStyle;
248
- }, [width, height, isNotVisible]);
248
+ }, [width, height, isNotVisible, styleProp]);
249
249
  React.useEffect(() => {
250
250
  if (!hasFocus || cellMode === GridCellModes.Edit) {
251
251
  return;
@@ -408,7 +408,8 @@ const GridCellV7 = /*#__PURE__*/React.forwardRef((props, ref) => {
408
408
  onKeyDown,
409
409
  onKeyUp,
410
410
  onDragEnter,
411
- onDragOver
411
+ onDragOver,
412
+ style: styleProp
412
413
  } = props,
413
414
  other = _objectWithoutPropertiesLoose(props, _excluded3);
414
415
  const apiRef = useGridApiContext();
@@ -499,22 +500,21 @@ const GridCellV7 = /*#__PURE__*/React.forwardRef((props, ref) => {
499
500
  }, [apiRef, field, rowId]);
500
501
  const style = React.useMemo(() => {
501
502
  if (isNotVisible) {
502
- return {
503
+ return _extends({
503
504
  padding: 0,
504
505
  opacity: 0,
505
506
  width: 0,
506
507
  border: 0
507
- };
508
+ }, styleProp);
508
509
  }
509
- const cellStyle = {
510
+ const cellStyle = _extends({
510
511
  minWidth: width,
511
512
  maxWidth: width,
512
513
  minHeight: height,
513
- maxHeight: height === 'auto' ? 'none' : height // max-height doesn't support "auto"
514
- };
515
-
514
+ maxHeight: height === 'auto' ? 'none' : height
515
+ }, styleProp);
516
516
  return cellStyle;
517
- }, [width, height, isNotVisible]);
517
+ }, [width, height, isNotVisible, styleProp]);
518
518
  React.useEffect(() => {
519
519
  if (!hasFocus || cellMode === GridCellModes.Edit) {
520
520
  return;
@@ -63,7 +63,6 @@ function GridEditDateCell(props) {
63
63
  classes: rootProps.classes
64
64
  };
65
65
  const classes = useUtilityClasses(ownerState);
66
- const hasUpdatedEditValueOnMount = React.useRef(false);
67
66
  const parseValueToDate = React.useCallback(value => {
68
67
  if (value === '') {
69
68
  return null;
@@ -109,26 +108,8 @@ function GridEditDateCell(props) {
109
108
  inputRef.current.focus();
110
109
  }
111
110
  }, [hasFocus]);
112
- const meta = apiRef.current.unstable_getEditCellMeta(id, field);
113
- const handleInputRef = el => {
114
- inputRef.current = el;
115
- if (meta != null && meta.unstable_updateValueOnRender && !hasUpdatedEditValueOnMount.current) {
116
- const inputValue = inputRef.current.value;
117
- const parsedDate = parseValueToDate(inputValue);
118
- setValueState({
119
- parsed: parsedDate,
120
- formatted: inputValue
121
- });
122
- apiRef.current.setEditCellValue({
123
- id,
124
- field,
125
- value: parsedDate
126
- });
127
- hasUpdatedEditValueOnMount.current = true;
128
- }
129
- };
130
111
  return /*#__PURE__*/_jsx(StyledInputBase, _extends({
131
- inputRef: handleInputRef,
112
+ inputRef: inputRef,
132
113
  fullWidth: true,
133
114
  className: classes.root,
134
115
  type: isDateTime ? 'datetime-local' : 'date',
@@ -7,6 +7,7 @@ import { gridColumnGroupsLookupSelector } from '../../hooks/features/columnGroup
7
7
  import { useGridApiContext } from '../../hooks/utils/useGridApiContext';
8
8
  import { useGridSelector } from '../../hooks/utils/useGridSelector';
9
9
  import { GridGenericColumnHeaderItem } from './GridGenericColumnHeaderItem';
10
+ import { isEventTargetInPortal } from '../../utils/domUtils';
10
11
  import { jsx as _jsx } from "react/jsx-runtime";
11
12
  const useUtilityClasses = ownerState => {
12
13
  const {
@@ -85,7 +86,7 @@ function GridColumnGroupHeader(props) {
85
86
  const publish = React.useCallback(eventName => event => {
86
87
  // Ignore portal
87
88
  // See https://github.com/mui/mui-x/issues/1721
88
- if (!event.currentTarget.contains(event.target)) {
89
+ if (isEventTargetInPortal(event)) {
89
90
  return;
90
91
  }
91
92
  apiRef.current.publishEvent(eventName, renderParams, event);
@@ -9,6 +9,7 @@ import { GridColumnHeaderMenu } from '../menu/columnMenu/GridColumnHeaderMenu';
9
9
  import { getDataGridUtilityClass } from '../../constants/gridClasses';
10
10
  import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
11
11
  import { GridGenericColumnHeaderItem } from './GridGenericColumnHeaderItem';
12
+ import { isEventTargetInPortal } from '../../utils/domUtils';
12
13
  import { jsx as _jsx } from "react/jsx-runtime";
13
14
  import { jsxs as _jsxs } from "react/jsx-runtime";
14
15
  const useUtilityClasses = ownerState => {
@@ -68,7 +69,7 @@ function GridColumnHeaderItem(props) {
68
69
  const publish = React.useCallback(eventName => event => {
69
70
  // Ignore portal
70
71
  // See https://github.com/mui/mui-x/issues/1721
71
- if (!event.currentTarget.contains(event.target)) {
72
+ if (isEventTargetInPortal(event)) {
72
73
  return;
73
74
  }
74
75
  apiRef.current.publishEvent(eventName, apiRef.current.getColumnHeaderParams(colDef.field), event);
@@ -178,8 +178,8 @@ const GridFilterForm = /*#__PURE__*/React.forwardRef(function GridFilterForm(pro
178
178
  // try to keep the same operator when column change
179
179
  const newOperator = column.filterOperators.find(operator => operator.value === item.operator) || column.filterOperators[0];
180
180
 
181
- // Erase filter value if the input component is modified
182
- const eraseItemValue = !newOperator.InputComponent || newOperator.InputComponent !== (currentOperator == null ? void 0 : currentOperator.InputComponent);
181
+ // Erase filter value if the input component or filtered column type is modified
182
+ const eraseItemValue = !newOperator.InputComponent || newOperator.InputComponent !== (currentOperator == null ? void 0 : currentOperator.InputComponent) || column.type !== currentColumn.type;
183
183
  applyFilterChanges(_extends({}, item, {
184
184
  field,
185
185
  operator: newOperator.value,
@@ -43,7 +43,7 @@ function GridFilterInputValue(props) {
43
43
  }, [id, applyValue, item, rootProps.filterDebounceMs, filterTimeout]);
44
44
  React.useEffect(() => {
45
45
  const itemPlusTag = item;
46
- if (itemPlusTag.fromInput !== id) {
46
+ if (itemPlusTag.fromInput !== id || item.value === undefined) {
47
47
  var _item$value2;
48
48
  setFilterValueState(String((_item$value2 = item.value) != null ? _item$value2 : ''));
49
49
  }
@@ -4,7 +4,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
4
4
  const _excluded = ["id", "field"],
5
5
  _excluded2 = ["id", "field"];
6
6
  import * as React from 'react';
7
- import { unstable_useEventCallback as useEventCallback } from '@mui/utils';
7
+ import { unstable_useEventCallback as useEventCallback, unstable_useEnhancedEffect as useEnhancedEffect } from '@mui/utils';
8
8
  import { useGridApiEventHandler, useGridApiOptionHandler } from '../../utils/useGridApiEventHandler';
9
9
  import { GridEditModes, GridCellModes } from '../../../models/gridEditRowModel';
10
10
  import { useGridApiMethod } from '../../utils/useGridApiMethod';
@@ -101,7 +101,7 @@ export const useGridCellEditing = (apiRef, props) => {
101
101
  if (isPrintableKey(event)) {
102
102
  reason = GridCellEditStartReasons.printableKeyDown;
103
103
  } else if ((event.ctrlKey || event.metaKey) && event.key === 'v') {
104
- reason = GridCellEditStartReasons.printableKeyDown;
104
+ reason = GridCellEditStartReasons.pasteKeyDown;
105
105
  } else if (event.key === 'Enter') {
106
106
  reason = GridCellEditStartReasons.enterKeyDown;
107
107
  } else if (event.key === 'Delete' || event.key === 'Backspace') {
@@ -121,24 +121,13 @@ export const useGridCellEditing = (apiRef, props) => {
121
121
  const {
122
122
  id,
123
123
  field,
124
- reason,
125
- key,
126
- colDef
124
+ reason
127
125
  } = params;
128
126
  const startCellEditModeParams = {
129
127
  id,
130
128
  field
131
129
  };
132
- if (reason === GridCellEditStartReasons.printableKeyDown) {
133
- if (React.version.startsWith('17')) {
134
- // In React 17, cleaning the input is enough.
135
- // The sequence of events makes the key pressed by the end-users update the textbox directly.
136
- startCellEditModeParams.deleteValue = true;
137
- } else {
138
- const initialValue = colDef.valueParser ? colDef.valueParser(key) : key;
139
- startCellEditModeParams.initialValue = initialValue;
140
- }
141
- } else if (reason === GridCellEditStartReasons.deleteKeyDown) {
130
+ if (reason === GridCellEditStartReasons.printableKeyDown || reason === GridCellEditStartReasons.deleteKeyDown || reason === GridCellEditStartReasons.pasteKeyDown) {
142
131
  startCellEditModeParams.deleteValue = true;
143
132
  }
144
133
  apiRef.current.startCellEditMode(startCellEditModeParams);
@@ -248,17 +237,13 @@ export const useGridCellEditing = (apiRef, props) => {
248
237
  initialValue
249
238
  } = params;
250
239
  let newValue = apiRef.current.getCellValue(id, field);
251
- // eslint-disable-next-line @typescript-eslint/naming-convention
252
- let unstable_updateValueOnRender = false;
253
240
  if (deleteValue || initialValue) {
254
241
  newValue = deleteValue ? '' : initialValue;
255
- unstable_updateValueOnRender = true;
256
242
  }
257
243
  const newProps = {
258
244
  value: newValue,
259
245
  error: false,
260
- isProcessingProps: false,
261
- unstable_updateValueOnRender
246
+ isProcessingProps: false
262
247
  };
263
248
  updateOrDeleteFieldState(id, field, newProps);
264
249
  apiRef.current.setCellFocus(id, field);
@@ -423,7 +408,9 @@ export const useGridCellEditing = (apiRef, props) => {
423
408
  updateCellModesModel(cellModesModelProp);
424
409
  }
425
410
  }, [cellModesModelProp, updateCellModesModel]);
426
- React.useEffect(() => {
411
+
412
+ // Run this effect synchronously so that the keyboard event can impact the yet-to-be-rendered input.
413
+ useEnhancedEffect(() => {
427
414
  const idToIdLookup = gridRowsDataRowIdToIdLookupSelector(apiRef);
428
415
 
429
416
  // Update the ref here because updateStateToStopCellEditMode may change it later
@@ -4,7 +4,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
4
4
  const _excluded = ["id"],
5
5
  _excluded2 = ["id"];
6
6
  import * as React from 'react';
7
- import { unstable_useEventCallback as useEventCallback } from '@mui/utils';
7
+ import { unstable_useEventCallback as useEventCallback, unstable_useEnhancedEffect as useEnhancedEffect } from '@mui/utils';
8
8
  import { useGridApiEventHandler, useGridApiOptionHandler } from '../../utils/useGridApiEventHandler';
9
9
  import { GridEditModes, GridRowModes } from '../../../models/gridEditRowModel';
10
10
  import { useGridApiMethod } from '../../utils/useGridApiMethod';
@@ -172,7 +172,6 @@ export const useGridRowEditing = (apiRef, props) => {
172
172
  const rowParams = apiRef.current.getRowParams(params.id);
173
173
  const newParams = _extends({}, rowParams, {
174
174
  field: params.field,
175
- key: event.key,
176
175
  reason
177
176
  });
178
177
  apiRef.current.publishEvent('rowEditStart', newParams, event);
@@ -183,24 +182,13 @@ export const useGridRowEditing = (apiRef, props) => {
183
182
  const {
184
183
  id,
185
184
  field,
186
- reason,
187
- key,
188
- columns
185
+ reason
189
186
  } = params;
190
187
  const startRowEditModeParams = {
191
188
  id,
192
189
  fieldToFocus: field
193
190
  };
194
- if (reason === GridRowEditStartReasons.printableKeyDown) {
195
- if (React.version.startsWith('17')) {
196
- // In React 17, cleaning the input is enough.
197
- // The sequence of events makes the key pressed by the end-users update the textbox directly.
198
- startRowEditModeParams.deleteValue = !!field;
199
- } else {
200
- const colDef = columns.find(col => col.field === field);
201
- startRowEditModeParams.initialValue = colDef.valueParser ? colDef.valueParser(key) : key;
202
- }
203
- } else if (reason === GridRowEditStartReasons.deleteKeyDown) {
191
+ if (reason === GridRowEditStartReasons.printableKeyDown || reason === GridRowEditStartReasons.deleteKeyDown) {
204
192
  startRowEditModeParams.deleteValue = !!field;
205
193
  }
206
194
  apiRef.current.startRowEditMode(startRowEditModeParams);
@@ -323,17 +311,13 @@ export const useGridRowEditing = (apiRef, props) => {
323
311
  return acc;
324
312
  }
325
313
  let newValue = apiRef.current.getCellValue(id, field);
326
- // eslint-disable-next-line @typescript-eslint/naming-convention
327
- let unstable_updateValueOnRender = false;
328
314
  if (fieldToFocus === field && (deleteValue || initialValue)) {
329
315
  newValue = deleteValue ? '' : initialValue;
330
- unstable_updateValueOnRender = true;
331
316
  }
332
317
  acc[field] = {
333
318
  value: newValue,
334
319
  error: false,
335
- isProcessingProps: false,
336
- unstable_updateValueOnRender
320
+ isProcessingProps: false
337
321
  };
338
322
  return acc;
339
323
  }, {});
@@ -553,7 +537,9 @@ export const useGridRowEditing = (apiRef, props) => {
553
537
  updateRowModesModel(rowModesModelProp);
554
538
  }
555
539
  }, [rowModesModelProp, updateRowModesModel]);
556
- React.useEffect(() => {
540
+
541
+ // Run this effect synchronously so that the keyboard event can impact the yet-to-be-rendered input.
542
+ useEnhancedEffect(() => {
557
543
  const idToIdLookup = gridRowsDataRowIdToIdLookupSelector(apiRef);
558
544
 
559
545
  // Update the ref here because updateStateToStopRowEditMode may change it later
@@ -15,6 +15,7 @@ import { unstable_gridFocusColumnGroupHeaderSelector } from '../focus';
15
15
  import { gridColumnGroupsHeaderMaxDepthSelector } from '../columnGrouping/gridColumnGroupsSelector';
16
16
  import { unstable_gridHeaderFilteringEditFieldSelector, unstable_gridHeaderFilteringMenuSelector } from '../headerFiltering/gridHeaderFilteringSelectors';
17
17
  import { useGridRegisterPipeProcessor } from '../../core/pipeProcessing';
18
+ import { isEventTargetInPortal } from '../../../utils/domUtils';
18
19
  function enrichPageRowsWithPinnedRows(apiRef, rows) {
19
20
  const pinnedRows = gridPinnedRowsSelector(apiRef) || {};
20
21
  return [...(pinnedRows.top || []), ...rows, ...(pinnedRows.bottom || [])];
@@ -414,7 +415,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
414
415
  }, [apiRef, currentPageRows.length, goToHeader, goToGroupHeader, goToCell, getRowIdFromIndex]);
415
416
  const handleCellKeyDown = React.useCallback((params, event) => {
416
417
  // Ignore portal
417
- if (!event.currentTarget.contains(event.target)) {
418
+ if (isEventTargetInPortal(event)) {
418
419
  return;
419
420
  }
420
421
 
@@ -14,6 +14,7 @@ import { isKeyboardEvent, isNavigationKey } from '../../../utils/keyboardUtils';
14
14
  import { useGridVisibleRows } from '../../utils/useGridVisibleRows';
15
15
  import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from '../../../constants/gridDetailPanelToggleField';
16
16
  import { gridClasses } from '../../../constants/gridClasses';
17
+ import { isEventTargetInPortal } from '../../../utils/domUtils';
17
18
  const getSelectionModelPropValue = (selectionModelProp, prevSelectionModel) => {
18
19
  if (selectionModelProp == null) {
19
20
  return selectionModelProp;
@@ -289,7 +290,7 @@ export const useGridRowSelection = (apiRef, props) => {
289
290
 
290
291
  // Ignore portal
291
292
  // Do not apply shortcuts if the focus is not on the cell root component
292
- if (!event.currentTarget.contains(event.target)) {
293
+ if (isEventTargetInPortal(event)) {
293
294
  return;
294
295
  }
295
296
  if (isNavigationKey(event.key) && event.shiftKey) {
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v6.18.2
2
+ * @mui/x-data-grid v6.18.4
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -67,7 +67,7 @@ export type { GridExperimentalFeatures, DataGridPropsWithoutDefaultValue, DataGr
67
67
  export { getColumnsToExport, defaultGetRowsToExport } from '../hooks/features/export/utils';
68
68
  export * from '../utils/createControllablePromise';
69
69
  export { createSelector, createSelectorMemoized, unstable_resetCreateSelectorCache, } from '../utils/createSelector';
70
- export { findParentElementFromClassName, getActiveElement } from '../utils/domUtils';
70
+ export { findParentElementFromClassName, getActiveElement, isEventTargetInPortal, } from '../utils/domUtils';
71
71
  export { isNavigationKey } from '../utils/keyboardUtils';
72
72
  export { clamp, isDeepEqual, isNumber, isFunction, isObject } from '../utils/utils';
73
73
  export { buildWarning } from '../utils/warning';
@@ -54,7 +54,7 @@ export { useGridInitializeState } from '../hooks/utils/useGridInitializeState';
54
54
  export { getColumnsToExport, defaultGetRowsToExport } from '../hooks/features/export/utils';
55
55
  export * from '../utils/createControllablePromise';
56
56
  export { createSelector, createSelectorMemoized, unstable_resetCreateSelectorCache } from '../utils/createSelector';
57
- export { findParentElementFromClassName, getActiveElement } from '../utils/domUtils';
57
+ export { findParentElementFromClassName, getActiveElement, isEventTargetInPortal } from '../utils/domUtils';
58
58
  export { isNavigationKey } from '../utils/keyboardUtils';
59
59
  export { clamp, isDeepEqual, isNumber, isFunction, isObject } from '../utils/utils';
60
60
  export { buildWarning } from '../utils/warning';
@@ -15,7 +15,7 @@ import { useGridRootProps } from '../hooks/utils/useGridRootProps';
15
15
  import { gridColumnsTotalWidthSelector } from '../hooks/features/columns/gridColumnsSelector';
16
16
  import { useGridSelector, objectShallowCompare } from '../hooks/utils/useGridSelector';
17
17
  import { useGridVisibleRows } from '../hooks/utils/useGridVisibleRows';
18
- import { findParentElementFromClassName } from '../utils/domUtils';
18
+ import { findParentElementFromClassName, isEventTargetInPortal } from '../utils/domUtils';
19
19
  import { GRID_CHECKBOX_SELECTION_COL_DEF } from '../colDef/gridCheckboxSelectionColDef';
20
20
  import { GRID_ACTIONS_COLUMN_TYPE } from '../colDef/gridActionsColDef';
21
21
  import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from '../constants/gridDetailPanelToggleField';
@@ -141,9 +141,7 @@ var GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
141
141
  var publish = React.useCallback(function (eventName, propHandler) {
142
142
  return function (event) {
143
143
  // Ignore portal
144
- // The target is not an element when triggered by a Select inside the cell
145
- // See https://github.com/mui/material-ui/issues/10534
146
- if (event.target.nodeType === 1 && !event.currentTarget.contains(event.target)) {
144
+ if (isEventTargetInPortal(event)) {
147
145
  return;
148
146
  }
149
147
 
@@ -1,8 +1,8 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
3
  var _excluded = ["changeReason", "unstable_updateValueOnRender"],
4
- _excluded2 = ["align", "children", "editCellState", "colIndex", "column", "cellMode", "field", "formattedValue", "hasFocus", "height", "isEditable", "isSelected", "rowId", "tabIndex", "value", "width", "className", "showRightBorder", "extendRowFullWidth", "row", "colSpan", "disableDragEvents", "isNotVisible", "onClick", "onDoubleClick", "onMouseDown", "onMouseUp", "onMouseOver", "onKeyDown", "onKeyUp", "onDragEnter", "onDragOver"],
5
- _excluded3 = ["column", "rowId", "editCellState", "align", "children", "colIndex", "height", "width", "className", "showRightBorder", "extendRowFullWidth", "row", "colSpan", "disableDragEvents", "isNotVisible", "onClick", "onDoubleClick", "onMouseDown", "onMouseUp", "onMouseOver", "onKeyDown", "onKeyUp", "onDragEnter", "onDragOver"],
4
+ _excluded2 = ["align", "children", "editCellState", "colIndex", "column", "cellMode", "field", "formattedValue", "hasFocus", "height", "isEditable", "isSelected", "rowId", "tabIndex", "style", "value", "width", "className", "showRightBorder", "extendRowFullWidth", "row", "colSpan", "disableDragEvents", "isNotVisible", "onClick", "onDoubleClick", "onMouseDown", "onMouseUp", "onMouseOver", "onKeyDown", "onKeyUp", "onDragEnter", "onDragOver"],
5
+ _excluded3 = ["column", "rowId", "editCellState", "align", "children", "colIndex", "height", "width", "className", "showRightBorder", "extendRowFullWidth", "row", "colSpan", "disableDragEvents", "isNotVisible", "onClick", "onDoubleClick", "onMouseDown", "onMouseUp", "onMouseOver", "onKeyDown", "onKeyUp", "onDragEnter", "onDragOver", "style"],
6
6
  _excluded4 = ["changeReason", "unstable_updateValueOnRender"];
7
7
  import * as React from 'react';
8
8
  import PropTypes from 'prop-types';
@@ -165,6 +165,7 @@ var GridCell = /*#__PURE__*/React.forwardRef(function (props, ref) {
165
165
  isSelected = props.isSelected,
166
166
  rowId = props.rowId,
167
167
  tabIndex = props.tabIndex,
168
+ styleProp = props.style,
168
169
  value = props.value,
169
170
  width = props.width,
170
171
  className = props.className,
@@ -238,15 +239,14 @@ var GridCell = /*#__PURE__*/React.forwardRef(function (props, ref) {
238
239
  border: 0
239
240
  };
240
241
  }
241
- var cellStyle = {
242
+ var cellStyle = _extends({
242
243
  minWidth: width,
243
244
  maxWidth: width,
244
245
  minHeight: height,
245
- maxHeight: height === 'auto' ? 'none' : height // max-height doesn't support "auto"
246
- };
247
-
246
+ maxHeight: height === 'auto' ? 'none' : height
247
+ }, styleProp);
248
248
  return cellStyle;
249
- }, [width, height, isNotVisible]);
249
+ }, [width, height, isNotVisible, styleProp]);
250
250
  React.useEffect(function () {
251
251
  if (!hasFocus || cellMode === GridCellModes.Edit) {
252
252
  return;
@@ -412,6 +412,7 @@ var GridCellV7 = /*#__PURE__*/React.forwardRef(function (props, ref) {
412
412
  onKeyUp = props.onKeyUp,
413
413
  onDragEnter = props.onDragEnter,
414
414
  onDragOver = props.onDragOver,
415
+ styleProp = props.style,
415
416
  other = _objectWithoutProperties(props, _excluded3);
416
417
  var apiRef = useGridApiContext();
417
418
  var rootProps = useGridRootProps();
@@ -507,22 +508,21 @@ var GridCellV7 = /*#__PURE__*/React.forwardRef(function (props, ref) {
507
508
  }, [apiRef, field, rowId]);
508
509
  var style = React.useMemo(function () {
509
510
  if (isNotVisible) {
510
- return {
511
+ return _extends({
511
512
  padding: 0,
512
513
  opacity: 0,
513
514
  width: 0,
514
515
  border: 0
515
- };
516
+ }, styleProp);
516
517
  }
517
- var cellStyle = {
518
+ var cellStyle = _extends({
518
519
  minWidth: width,
519
520
  maxWidth: width,
520
521
  minHeight: height,
521
- maxHeight: height === 'auto' ? 'none' : height // max-height doesn't support "auto"
522
- };
523
-
522
+ maxHeight: height === 'auto' ? 'none' : height
523
+ }, styleProp);
524
524
  return cellStyle;
525
- }, [width, height, isNotVisible]);
525
+ }, [width, height, isNotVisible, styleProp]);
526
526
  React.useEffect(function () {
527
527
  if (!hasFocus || cellMode === GridCellModes.Edit) {
528
528
  return;