@mui/x-data-grid 6.18.1 → 6.18.3
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.
- package/CHANGELOG.md +112 -0
- package/components/GridRow.js +2 -4
- package/components/cell/GridEditDateCell.js +1 -20
- package/components/columnHeaders/GridColumnGroupHeader.js +2 -1
- package/components/columnHeaders/GridColumnHeaderItem.js +2 -1
- package/components/panel/filterPanel/GridFilterForm.js +2 -2
- package/components/panel/filterPanel/GridFilterInputValue.js +1 -1
- package/hooks/features/editing/useGridCellEditing.js +8 -21
- package/hooks/features/editing/useGridRowEditing.js +7 -21
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -1
- package/hooks/features/rowSelection/useGridRowSelection.js +2 -1
- package/index.js +1 -1
- package/internals/index.d.ts +1 -1
- package/internals/index.js +1 -1
- package/legacy/components/GridRow.js +2 -4
- package/legacy/components/cell/GridEditDateCell.js +1 -20
- package/legacy/components/columnHeaders/GridColumnGroupHeader.js +2 -1
- package/legacy/components/columnHeaders/GridColumnHeaderItem.js +2 -1
- package/legacy/components/panel/filterPanel/GridFilterForm.js +2 -2
- package/legacy/components/panel/filterPanel/GridFilterInputValue.js +1 -1
- package/legacy/hooks/features/editing/useGridCellEditing.js +8 -21
- package/legacy/hooks/features/editing/useGridRowEditing.js +7 -23
- package/legacy/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -1
- package/legacy/hooks/features/rowSelection/useGridRowSelection.js +2 -1
- package/legacy/index.js +1 -1
- package/legacy/internals/index.js +1 -1
- package/legacy/locales/arSD.js +1 -1
- package/legacy/locales/bgBG.js +33 -37
- package/legacy/locales/csCZ.js +2 -2
- package/legacy/locales/heIL.js +1 -2
- package/legacy/models/params/gridEditCellParams.js +1 -0
- package/legacy/utils/domUtils.js +10 -1
- package/locales/arSD.js +1 -1
- package/locales/bgBG.js +33 -37
- package/locales/csCZ.js +2 -2
- package/locales/heIL.js +1 -2
- package/models/api/gridEditingApi.d.ts +2 -4
- package/models/params/gridEditCellParams.d.ts +3 -1
- package/models/params/gridEditCellParams.js +1 -0
- package/models/params/gridRowParams.d.ts +1 -0
- package/modern/components/GridRow.js +2 -4
- package/modern/components/cell/GridEditDateCell.js +1 -20
- package/modern/components/columnHeaders/GridColumnGroupHeader.js +2 -1
- package/modern/components/columnHeaders/GridColumnHeaderItem.js +2 -1
- package/modern/components/panel/filterPanel/GridFilterForm.js +2 -2
- package/modern/components/panel/filterPanel/GridFilterInputValue.js +1 -1
- package/modern/hooks/features/editing/useGridCellEditing.js +8 -21
- package/modern/hooks/features/editing/useGridRowEditing.js +7 -21
- package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -1
- package/modern/hooks/features/rowSelection/useGridRowSelection.js +2 -1
- package/modern/index.js +1 -1
- package/modern/internals/index.js +1 -1
- package/modern/locales/arSD.js +1 -1
- package/modern/locales/bgBG.js +33 -37
- package/modern/locales/csCZ.js +2 -2
- package/modern/locales/heIL.js +1 -2
- package/modern/models/params/gridEditCellParams.js +1 -0
- package/modern/utils/domUtils.js +10 -1
- package/node/components/GridRow.js +1 -3
- package/node/components/cell/GridEditDateCell.js +1 -20
- package/node/components/columnHeaders/GridColumnGroupHeader.js +2 -1
- package/node/components/columnHeaders/GridColumnHeaderItem.js +2 -1
- package/node/components/panel/filterPanel/GridFilterForm.js +2 -2
- package/node/components/panel/filterPanel/GridFilterInputValue.js +1 -1
- package/node/hooks/features/editing/useGridCellEditing.js +7 -20
- package/node/hooks/features/editing/useGridRowEditing.js +6 -20
- package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -1
- package/node/hooks/features/rowSelection/useGridRowSelection.js +2 -1
- package/node/index.js +1 -1
- package/node/internals/index.js +7 -0
- package/node/locales/arSD.js +1 -1
- package/node/locales/bgBG.js +33 -37
- package/node/locales/csCZ.js +2 -2
- package/node/locales/heIL.js +1 -2
- package/node/models/params/gridEditCellParams.js +1 -0
- package/node/utils/domUtils.js +11 -1
- package/package.json +1 -1
- package/utils/domUtils.d.ts +2 -0
- package/utils/domUtils.js +10 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,118 @@
|
|
|
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.3
|
|
7
|
+
|
|
8
|
+
_Dec 4, 2023_
|
|
9
|
+
|
|
10
|
+
We'd like to offer a big thanks to the 10 contributors who made this release possible. Here are some highlights ✨:
|
|
11
|
+
|
|
12
|
+
- 📈 Fix a lot of Charts package issues
|
|
13
|
+
- 🌍 Improve Bulgarian (bg-BG) locale on Data Grid
|
|
14
|
+
- 🐞 Bugfixes
|
|
15
|
+
- 📚 Documentation improvements
|
|
16
|
+
|
|
17
|
+
### Data Grid
|
|
18
|
+
|
|
19
|
+
#### `@mui/x-data-grid@6.18.3`
|
|
20
|
+
|
|
21
|
+
- [DataGrid] Fix cell editing adding a leading "v" on paste (#11166) @prasad5795
|
|
22
|
+
- [DataGrid] Fix handling of event target in portal (#11209) @cherniavskii
|
|
23
|
+
- [DataGrid] Fix `onFilterModelChange` being fired with stale field value (#11244) @gitstart
|
|
24
|
+
- [l10n] Improve Bulgarian (bg-BG) locale (#10856) (#11206) @Kristiqn95
|
|
25
|
+
|
|
26
|
+
#### `@mui/x-data-grid-pro@6.18.3` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
27
|
+
|
|
28
|
+
Same changes as in `@mui/x-data-grid@6.18.3`.
|
|
29
|
+
|
|
30
|
+
#### `@mui/x-data-grid-premium@6.18.3` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
31
|
+
|
|
32
|
+
Same changes as in `@mui/x-data-grid-pro@6.18.3`, plus:
|
|
33
|
+
|
|
34
|
+
- [DataGridPremium] Fix aggregated column ignoring column definition changes (#11176) @cherniavskii
|
|
35
|
+
- [DataGridPremium] Fix custom filter operators not working on aggregated column (#11201) @cherniavskii
|
|
36
|
+
|
|
37
|
+
### Date Pickers
|
|
38
|
+
|
|
39
|
+
#### `@mui/x-date-pickers@6.18.3`
|
|
40
|
+
|
|
41
|
+
- [pickers] Correctly format `MultiSectionDigitalClock` number sections (#11297) @LukasTy
|
|
42
|
+
- [pickers] Expand field placeholder methods flexibility by providing `format` parameter (#11254) @LukasTy
|
|
43
|
+
|
|
44
|
+
#### `@mui/x-date-pickers-pro@6.18.3` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
45
|
+
|
|
46
|
+
Same changes as in `@mui/x-date-pickers@6.18.3`.
|
|
47
|
+
|
|
48
|
+
### Charts / `@mui/x-charts@6.18.3`
|
|
49
|
+
|
|
50
|
+
- [charts] Adjusted `defaultizeValueFormatter` util to accept an optional `series.valueFormatter` value (#11213) @michelengelen
|
|
51
|
+
- [charts] Apply `labelStyle` and `tickLabelStyle` props on `<ChartsYAxis />` (#11180) @akamfoad
|
|
52
|
+
- [charts] Fix TS config (#11259) @alexfauquette
|
|
53
|
+
- [charts] Fix error with empty dataset (#11063) @alexfauquette
|
|
54
|
+
- [charts] Fix export strategy (#11235) @alexfauquette
|
|
55
|
+
|
|
56
|
+
### Docs
|
|
57
|
+
|
|
58
|
+
- [docs] Add LTS section to support page (#11300) @joserodolfofreitas
|
|
59
|
+
- [docs] Add end v6 blogpost to whats new page (#11299) @joserodolfofreitas
|
|
60
|
+
- [docs] Document charts composition (#10710) @alexfauquette
|
|
61
|
+
- [docs] Fix version links (#11167) @LukasTy
|
|
62
|
+
- [docs] Improve Data Grid togglable columns example (#11241) @MBilalShafi
|
|
63
|
+
- [docs] Split charts overview and getting started in distinct pages (#10910) @alexfauquette
|
|
64
|
+
|
|
65
|
+
## 6.18.2
|
|
66
|
+
|
|
67
|
+
_Nov 23, 2023_
|
|
68
|
+
|
|
69
|
+
We'd like to offer a big thanks to the 11 contributors who made this release possible. Here are some highlights ✨:
|
|
70
|
+
|
|
71
|
+
- 🌍 Improve Arabic (ar-SD), Czech (cs-CZ), and Hebrew (he-IL) locales on Data Grid
|
|
72
|
+
- 🌍 Add Basque (eu) and Macedonian (mk) locales on Pickers
|
|
73
|
+
- 🌍 Improve German (de-DE) and Spanish (es-ES) locales on Pickers
|
|
74
|
+
- 🐞 Bugfixes
|
|
75
|
+
- 📚 Documentation improvements
|
|
76
|
+
|
|
77
|
+
### Data Grid
|
|
78
|
+
|
|
79
|
+
#### `@mui/x-data-grid@6.18.2`
|
|
80
|
+
|
|
81
|
+
- [l10n] Improve Arabic (ar-SD) locale (#11096) @OmarWebDev
|
|
82
|
+
- [l10n] Improve Czech (cs-CZ) locale (#10968) @luborepka
|
|
83
|
+
- [l10n] Improve Hebrew (he-IL) locale (#11056) @LironKiloma
|
|
84
|
+
|
|
85
|
+
#### `@mui/x-data-grid-pro@6.18.2` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
86
|
+
|
|
87
|
+
Same changes as in `@mui/x-data-grid@6.18.2`.
|
|
88
|
+
|
|
89
|
+
#### `@mui/x-data-grid-premium@6.18.2` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
90
|
+
|
|
91
|
+
Same changes as in `@mui/x-data-grid-pro@6.18.2`.
|
|
92
|
+
|
|
93
|
+
### Date Pickers
|
|
94
|
+
|
|
95
|
+
#### `@mui/x-date-pickers@6.18.2`
|
|
96
|
+
|
|
97
|
+
- [l10n] Add Basque (eu) locale and improve Spanish (es-ES) locale (#10985) @lajtomekadimon
|
|
98
|
+
- [l10n] Add Macedonian (mk) locale (#11155) @brsnik
|
|
99
|
+
- [l10n] Improve German (de-DE) locale (#11104) @jho-vema
|
|
100
|
+
- [pickers] Deprecate `defaultCalendarMonth` prop (#11138) @flaviendelangle
|
|
101
|
+
- [pickers] Fix `DateCalendar` crashing when given an invalid value (#11101) @flaviendelangle
|
|
102
|
+
|
|
103
|
+
#### `@mui/x-date-pickers-pro@6.18.2` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
104
|
+
|
|
105
|
+
Same changes as in `@mui/x-date-pickers@6.18.2`.
|
|
106
|
+
|
|
107
|
+
### Charts / `@mui/x-charts@6.18.2`
|
|
108
|
+
|
|
109
|
+
- [charts] Fix `ChartsTooltip` component setup (#11157) @LukasTy
|
|
110
|
+
- [charts] Remove outdated prop-types (#10998) @alexfauquette
|
|
111
|
+
|
|
112
|
+
### Docs
|
|
113
|
+
|
|
114
|
+
- [docs] Fix incoherent naming of a component in `Custom slots and subcomponents` page (#11003) @lhilgert9
|
|
115
|
+
- [test] Skip flaky e2e test in webkit (#11115) @cherniavskii
|
|
116
|
+
- [test] Wait for images to load (#11109) @cherniavskii
|
|
117
|
+
|
|
6
118
|
## 6.18.1
|
|
7
119
|
|
|
8
120
|
_Nov 9, 2023_
|
package/components/GridRow.js
CHANGED
|
@@ -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
|
-
|
|
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
|
|
|
@@ -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:
|
|
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 (
|
|
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 (
|
|
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.
|
|
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
|
-
|
|
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
|
-
|
|
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 (
|
|
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 (
|
|
293
|
+
if (isEventTargetInPortal(event)) {
|
|
293
294
|
return;
|
|
294
295
|
}
|
|
295
296
|
if (isNavigationKey(event.key) && event.shiftKey) {
|
package/index.js
CHANGED
package/internals/index.d.ts
CHANGED
|
@@ -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';
|
package/internals/index.js
CHANGED
|
@@ -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
|
-
|
|
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
|
|
|
@@ -74,7 +74,6 @@ function GridEditDateCell(props) {
|
|
|
74
74
|
classes: rootProps.classes
|
|
75
75
|
};
|
|
76
76
|
var classes = useUtilityClasses(ownerState);
|
|
77
|
-
var hasUpdatedEditValueOnMount = React.useRef(false);
|
|
78
77
|
var parseValueToDate = React.useCallback(function (value) {
|
|
79
78
|
if (value === '') {
|
|
80
79
|
return null;
|
|
@@ -148,26 +147,8 @@ function GridEditDateCell(props) {
|
|
|
148
147
|
inputRef.current.focus();
|
|
149
148
|
}
|
|
150
149
|
}, [hasFocus]);
|
|
151
|
-
var meta = apiRef.current.unstable_getEditCellMeta(id, field);
|
|
152
|
-
var handleInputRef = function handleInputRef(el) {
|
|
153
|
-
inputRef.current = el;
|
|
154
|
-
if (meta != null && meta.unstable_updateValueOnRender && !hasUpdatedEditValueOnMount.current) {
|
|
155
|
-
var inputValue = inputRef.current.value;
|
|
156
|
-
var parsedDate = parseValueToDate(inputValue);
|
|
157
|
-
setValueState({
|
|
158
|
-
parsed: parsedDate,
|
|
159
|
-
formatted: inputValue
|
|
160
|
-
});
|
|
161
|
-
apiRef.current.setEditCellValue({
|
|
162
|
-
id: id,
|
|
163
|
-
field: field,
|
|
164
|
-
value: parsedDate
|
|
165
|
-
});
|
|
166
|
-
hasUpdatedEditValueOnMount.current = true;
|
|
167
|
-
}
|
|
168
|
-
};
|
|
169
150
|
return /*#__PURE__*/_jsx(StyledInputBase, _extends({
|
|
170
|
-
inputRef:
|
|
151
|
+
inputRef: inputRef,
|
|
171
152
|
fullWidth: true,
|
|
172
153
|
className: classes.root,
|
|
173
154
|
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
|
var useUtilityClasses = function useUtilityClasses(ownerState) {
|
|
12
13
|
var classes = ownerState.classes,
|
|
@@ -85,7 +86,7 @@ function GridColumnGroupHeader(props) {
|
|
|
85
86
|
return function (event) {
|
|
86
87
|
// Ignore portal
|
|
87
88
|
// See https://github.com/mui/mui-x/issues/1721
|
|
88
|
-
if (
|
|
89
|
+
if (isEventTargetInPortal(event)) {
|
|
89
90
|
return;
|
|
90
91
|
}
|
|
91
92
|
apiRef.current.publishEvent(eventName, renderParams, event);
|
|
@@ -10,6 +10,7 @@ import { GridColumnHeaderMenu } from '../menu/columnMenu/GridColumnHeaderMenu';
|
|
|
10
10
|
import { getDataGridUtilityClass } from '../../constants/gridClasses';
|
|
11
11
|
import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
|
|
12
12
|
import { GridGenericColumnHeaderItem } from './GridGenericColumnHeaderItem';
|
|
13
|
+
import { isEventTargetInPortal } from '../../utils/domUtils';
|
|
13
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
15
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
16
|
var useUtilityClasses = function useUtilityClasses(ownerState) {
|
|
@@ -71,7 +72,7 @@ function GridColumnHeaderItem(props) {
|
|
|
71
72
|
return function (event) {
|
|
72
73
|
// Ignore portal
|
|
73
74
|
// See https://github.com/mui/mui-x/issues/1721
|
|
74
|
-
if (
|
|
75
|
+
if (isEventTargetInPortal(event)) {
|
|
75
76
|
return;
|
|
76
77
|
}
|
|
77
78
|
apiRef.current.publishEvent(eventName, apiRef.current.getColumnHeaderParams(colDef.field), event);
|
|
@@ -205,8 +205,8 @@ var GridFilterForm = /*#__PURE__*/React.forwardRef(function GridFilterForm(props
|
|
|
205
205
|
return operator.value === item.operator;
|
|
206
206
|
}) || column.filterOperators[0];
|
|
207
207
|
|
|
208
|
-
// Erase filter value if the input component is modified
|
|
209
|
-
var eraseItemValue = !newOperator.InputComponent || newOperator.InputComponent !== (currentOperator == null ? void 0 : currentOperator.InputComponent);
|
|
208
|
+
// Erase filter value if the input component or filtered column type is modified
|
|
209
|
+
var eraseItemValue = !newOperator.InputComponent || newOperator.InputComponent !== (currentOperator == null ? void 0 : currentOperator.InputComponent) || column.type !== currentColumn.type;
|
|
210
210
|
applyFilterChanges(_extends({}, item, {
|
|
211
211
|
field: field,
|
|
212
212
|
operator: newOperator.value,
|
|
@@ -47,7 +47,7 @@ function GridFilterInputValue(props) {
|
|
|
47
47
|
}, [id, applyValue, item, rootProps.filterDebounceMs, filterTimeout]);
|
|
48
48
|
React.useEffect(function () {
|
|
49
49
|
var itemPlusTag = item;
|
|
50
|
-
if (itemPlusTag.fromInput !== id) {
|
|
50
|
+
if (itemPlusTag.fromInput !== id || item.value === undefined) {
|
|
51
51
|
var _item$value2;
|
|
52
52
|
setFilterValueState(String((_item$value2 = item.value) != null ? _item$value2 : ''));
|
|
53
53
|
}
|
|
@@ -8,7 +8,7 @@ var _excluded = ["id", "field"],
|
|
|
8
8
|
_excluded2 = ["id", "field"];
|
|
9
9
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
10
10
|
import * as React from 'react';
|
|
11
|
-
import { unstable_useEventCallback as useEventCallback } from '@mui/utils';
|
|
11
|
+
import { unstable_useEventCallback as useEventCallback, unstable_useEnhancedEffect as useEnhancedEffect } from '@mui/utils';
|
|
12
12
|
import { useGridApiEventHandler, useGridApiOptionHandler } from '../../utils/useGridApiEventHandler';
|
|
13
13
|
import { GridEditModes, GridCellModes } from '../../../models/gridEditRowModel';
|
|
14
14
|
import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
@@ -108,7 +108,7 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
|
|
|
108
108
|
if (isPrintableKey(event)) {
|
|
109
109
|
_reason = GridCellEditStartReasons.printableKeyDown;
|
|
110
110
|
} else if ((event.ctrlKey || event.metaKey) && event.key === 'v') {
|
|
111
|
-
_reason = GridCellEditStartReasons.
|
|
111
|
+
_reason = GridCellEditStartReasons.pasteKeyDown;
|
|
112
112
|
} else if (event.key === 'Enter') {
|
|
113
113
|
_reason = GridCellEditStartReasons.enterKeyDown;
|
|
114
114
|
} else if (event.key === 'Delete' || event.key === 'Backspace') {
|
|
@@ -127,23 +127,12 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
|
|
|
127
127
|
var handleCellEditStart = React.useCallback(function (params) {
|
|
128
128
|
var id = params.id,
|
|
129
129
|
field = params.field,
|
|
130
|
-
reason = params.reason
|
|
131
|
-
key = params.key,
|
|
132
|
-
colDef = params.colDef;
|
|
130
|
+
reason = params.reason;
|
|
133
131
|
var startCellEditModeParams = {
|
|
134
132
|
id: id,
|
|
135
133
|
field: field
|
|
136
134
|
};
|
|
137
|
-
if (reason === GridCellEditStartReasons.printableKeyDown) {
|
|
138
|
-
if (React.version.startsWith('17')) {
|
|
139
|
-
// In React 17, cleaning the input is enough.
|
|
140
|
-
// The sequence of events makes the key pressed by the end-users update the textbox directly.
|
|
141
|
-
startCellEditModeParams.deleteValue = true;
|
|
142
|
-
} else {
|
|
143
|
-
var initialValue = colDef.valueParser ? colDef.valueParser(key) : key;
|
|
144
|
-
startCellEditModeParams.initialValue = initialValue;
|
|
145
|
-
}
|
|
146
|
-
} else if (reason === GridCellEditStartReasons.deleteKeyDown) {
|
|
135
|
+
if (reason === GridCellEditStartReasons.printableKeyDown || reason === GridCellEditStartReasons.deleteKeyDown || reason === GridCellEditStartReasons.pasteKeyDown) {
|
|
147
136
|
startCellEditModeParams.deleteValue = true;
|
|
148
137
|
}
|
|
149
138
|
apiRef.current.startCellEditMode(startCellEditModeParams);
|
|
@@ -244,17 +233,13 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
|
|
|
244
233
|
deleteValue = params.deleteValue,
|
|
245
234
|
initialValue = params.initialValue;
|
|
246
235
|
var newValue = apiRef.current.getCellValue(id, field);
|
|
247
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
248
|
-
var unstable_updateValueOnRender = false;
|
|
249
236
|
if (deleteValue || initialValue) {
|
|
250
237
|
newValue = deleteValue ? '' : initialValue;
|
|
251
|
-
unstable_updateValueOnRender = true;
|
|
252
238
|
}
|
|
253
239
|
var newProps = {
|
|
254
240
|
value: newValue,
|
|
255
241
|
error: false,
|
|
256
|
-
isProcessingProps: false
|
|
257
|
-
unstable_updateValueOnRender: unstable_updateValueOnRender
|
|
242
|
+
isProcessingProps: false
|
|
258
243
|
};
|
|
259
244
|
updateOrDeleteFieldState(id, field, newProps);
|
|
260
245
|
apiRef.current.setCellFocus(id, field);
|
|
@@ -439,7 +424,9 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
|
|
|
439
424
|
updateCellModesModel(cellModesModelProp);
|
|
440
425
|
}
|
|
441
426
|
}, [cellModesModelProp, updateCellModesModel]);
|
|
442
|
-
|
|
427
|
+
|
|
428
|
+
// Run this effect synchronously so that the keyboard event can impact the yet-to-be-rendered input.
|
|
429
|
+
useEnhancedEffect(function () {
|
|
443
430
|
var idToIdLookup = gridRowsDataRowIdToIdLookupSelector(apiRef);
|
|
444
431
|
|
|
445
432
|
// Update the ref here because updateStateToStopCellEditMode may change it later
|