@mui/x-data-grid 5.17.1 → 5.17.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.
- package/CHANGELOG.md +44 -0
- package/hooks/features/editRows/useGridCellEditing.new.js +8 -2
- package/hooks/features/editRows/useGridRowEditing.new.js +8 -2
- package/index.js +1 -1
- package/legacy/hooks/features/editRows/useGridCellEditing.new.js +11 -5
- package/legacy/hooks/features/editRows/useGridRowEditing.new.js +8 -2
- package/legacy/index.js +1 -1
- package/legacy/utils/utils.js +7 -0
- package/modern/hooks/features/editRows/useGridCellEditing.new.js +8 -2
- package/modern/hooks/features/editRows/useGridRowEditing.new.js +8 -2
- package/modern/index.js +1 -1
- package/modern/utils/utils.js +7 -0
- package/node/hooks/features/editRows/useGridCellEditing.new.js +9 -2
- package/node/hooks/features/editRows/useGridRowEditing.new.js +9 -2
- package/node/index.js +1 -1
- package/node/utils/utils.js +9 -0
- package/package.json +1 -1
- package/utils/utils.d.ts +1 -0
- package/utils/utils.js +7 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,50 @@
|
|
|
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
|
+
## 5.17.2
|
|
7
|
+
|
|
8
|
+
_Sep 9, 2022_
|
|
9
|
+
|
|
10
|
+
This release will the last regular release for our `v5` packages.
|
|
11
|
+
From now on, we'll be focusing on developing MUI X v6.
|
|
12
|
+
You can check the [roadmap](https://github.com/mui/mui-x/projects/1) for more details on what's coming next.
|
|
13
|
+
|
|
14
|
+
And if you'd like to help, please consider volunteering to give us a [user interview](https://docs.google.com/forms/d/11L_zxL7oD_B-ZrZDuSyIkUzJLzOTUU2M4vHXxMVtWhU/edit).
|
|
15
|
+
We'd love to know more about your use cases, pain points and expectations for the future.
|
|
16
|
+
|
|
17
|
+
The `v5` packages will only get new versions to patch critical bug fixes.
|
|
18
|
+
|
|
19
|
+
We'd like to offer a big thanks to the 6 contributors who made this release possible. Here are some highlights ✨:
|
|
20
|
+
|
|
21
|
+
- 📃 Add support for column grouping when exporting to Excel (#5895) @alexfauquette
|
|
22
|
+
- 🐞 Bugfixes
|
|
23
|
+
|
|
24
|
+
### `@mui/x-data-grid@v5.17.2` / `@mui/x-data-grid-pro@v5.17.2` / `@mui/x-data-grid-premium@v5.17.2`
|
|
25
|
+
|
|
26
|
+
#### Changes
|
|
27
|
+
|
|
28
|
+
- [DataGrid] Revert mode if cell/row couldn't be saved due to validation error (#5897) @m4theushw
|
|
29
|
+
- [DataGridPremium] Export column grouping in Excel (#5895) @alexfauquette
|
|
30
|
+
|
|
31
|
+
### `@mui/x-date-pickers@v5.0.1` / `@mui/x-date-pickers-pro@v5.0.1`
|
|
32
|
+
|
|
33
|
+
#### Changes
|
|
34
|
+
|
|
35
|
+
- [DateTimePicker] Remove circular import (#6087) @flaviendelangle
|
|
36
|
+
- [pickers] Add `sx` prop to the equality check of `PickersDay` (#6030) @TheUnlocked
|
|
37
|
+
- [pickers] Add warning when `openTo` is invalid based on available `views` (#6042) @LukasTy
|
|
38
|
+
- [pickers] Allow keyboard navigation to ignore disabled date for left / right arrow (#6082) @alexfauquette
|
|
39
|
+
- [pickers] Fix mobile picker not opening on label click (#6074) @LukasTy
|
|
40
|
+
|
|
41
|
+
### Docs
|
|
42
|
+
|
|
43
|
+
- [docs] Add Recipes section
|
|
44
|
+
|
|
45
|
+
### Core
|
|
46
|
+
|
|
47
|
+
- [core] Add `yarn release:tag` script (#5169) @DanailH
|
|
48
|
+
- [core] Upgrade monorepo (#6072) @m4theushw
|
|
49
|
+
|
|
6
50
|
## 5.17.1
|
|
7
51
|
|
|
8
52
|
_Sep 5, 2022_
|
|
@@ -11,6 +11,7 @@ import { gridEditRowsStateSelector } from './gridEditRowsSelector';
|
|
|
11
11
|
import { isPrintableKey } from '../../../utils/keyboardUtils';
|
|
12
12
|
import { buildWarning } from '../../../utils/warning';
|
|
13
13
|
import { gridRowsIdToIdLookupSelector } from '../rows/gridRowsSelector';
|
|
14
|
+
import { deepClone } from '../../../utils/utils';
|
|
14
15
|
import { GridCellEditStartReasons, GridCellEditStopReasons } from '../../../models/params/gridEditCellParams';
|
|
15
16
|
const missingOnProcessRowUpdateErrorWarning = buildWarning(['MUI: A call to `processRowUpdate` threw an error which was not handled because `onProcessRowUpdateError` is missing.', 'To handle the error pass a callback to the `onProcessRowUpdateError` prop, e.g. `<DataGrid onProcessRowUpdateError={(error) => ...} />`.', 'For more detail, see http://mui.com/components/data-grid/editing/#persistence.'], 'error');
|
|
16
17
|
export const useGridCellEditing = (apiRef, props) => {
|
|
@@ -319,7 +320,11 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
319
320
|
if (error || isProcessingProps) {
|
|
320
321
|
// Attempt to change cell mode to "view" was not successful
|
|
321
322
|
// Update previous mode to allow another attempt
|
|
322
|
-
prevCellModesModel.current[id][field].mode = GridCellModes.Edit;
|
|
323
|
+
prevCellModesModel.current[id][field].mode = GridCellModes.Edit; // Revert the mode in the cellModesModel prop back to "edit"
|
|
324
|
+
|
|
325
|
+
updateFieldInCellModesModel(id, field, {
|
|
326
|
+
mode: GridCellModes.Edit
|
|
327
|
+
});
|
|
323
328
|
return;
|
|
324
329
|
}
|
|
325
330
|
|
|
@@ -437,7 +442,8 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
437
442
|
const idToIdLookup = gridRowsIdToIdLookupSelector(apiRef); // Update the ref here because updateStateToStopCellEditMode may change it later
|
|
438
443
|
|
|
439
444
|
const copyOfPrevCellModes = prevCellModesModel.current;
|
|
440
|
-
prevCellModesModel.current = cellModesModel;
|
|
445
|
+
prevCellModesModel.current = deepClone(cellModesModel); // Do a deep-clone because the attributes might be changed later
|
|
446
|
+
|
|
441
447
|
Object.entries(cellModesModel).forEach(([id, fields]) => {
|
|
442
448
|
Object.entries(fields).forEach(([field, params]) => {
|
|
443
449
|
var _copyOfPrevCellModes$, _copyOfPrevCellModes$2, _idToIdLookup$id;
|
|
@@ -12,6 +12,7 @@ import { isPrintableKey } from '../../../utils/keyboardUtils';
|
|
|
12
12
|
import { gridColumnFieldsSelector } from '../columns/gridColumnsSelector';
|
|
13
13
|
import { buildWarning } from '../../../utils/warning';
|
|
14
14
|
import { gridRowsIdToIdLookupSelector } from '../rows/gridRowsSelector';
|
|
15
|
+
import { deepClone } from '../../../utils/utils';
|
|
15
16
|
import { GridRowEditStopReasons, GridRowEditStartReasons } from '../../../models/params/gridRowParams';
|
|
16
17
|
const missingOnProcessRowUpdateErrorWarning = buildWarning(['MUI: A call to `processRowUpdate` threw an error which was not handled because `onProcessRowUpdateError` is missing.', 'To handle the error pass a callback to the `onProcessRowUpdateError` prop, e.g. `<DataGrid onProcessRowUpdateError={(error) => ...} />`.', 'For more detail, see http://mui.com/components/data-grid/editing/#persistence.'], 'error');
|
|
17
18
|
export const useGridRowEditing = (apiRef, props) => {
|
|
@@ -403,7 +404,11 @@ export const useGridRowEditing = (apiRef, props) => {
|
|
|
403
404
|
const hasSomeFieldWithError = Object.values(editingState[id]).some(fieldProps => fieldProps.error);
|
|
404
405
|
|
|
405
406
|
if (hasSomeFieldWithError) {
|
|
406
|
-
prevRowModesModel.current[id].mode = GridRowModes.Edit;
|
|
407
|
+
prevRowModesModel.current[id].mode = GridRowModes.Edit; // Revert the mode in the rowModesModel prop back to "edit"
|
|
408
|
+
|
|
409
|
+
updateRowInRowModesModel(id, {
|
|
410
|
+
mode: GridRowModes.Edit
|
|
411
|
+
});
|
|
407
412
|
return;
|
|
408
413
|
}
|
|
409
414
|
|
|
@@ -586,7 +591,8 @@ export const useGridRowEditing = (apiRef, props) => {
|
|
|
586
591
|
const idToIdLookup = gridRowsIdToIdLookupSelector(apiRef); // Update the ref here because updateStateToStopRowEditMode may change it later
|
|
587
592
|
|
|
588
593
|
const copyOfPrevRowModesModel = prevRowModesModel.current;
|
|
589
|
-
prevRowModesModel.current = rowModesModel;
|
|
594
|
+
prevRowModesModel.current = deepClone(rowModesModel); // Do a deep-clone because the attributes might be changed later
|
|
595
|
+
|
|
590
596
|
Object.entries(rowModesModel).forEach(([id, params]) => {
|
|
591
597
|
var _copyOfPrevRowModesMo, _idToIdLookup$id;
|
|
592
598
|
|
package/index.js
CHANGED
|
@@ -15,6 +15,7 @@ import { gridEditRowsStateSelector } from './gridEditRowsSelector';
|
|
|
15
15
|
import { isPrintableKey } from '../../../utils/keyboardUtils';
|
|
16
16
|
import { buildWarning } from '../../../utils/warning';
|
|
17
17
|
import { gridRowsIdToIdLookupSelector } from '../rows/gridRowsSelector';
|
|
18
|
+
import { deepClone } from '../../../utils/utils';
|
|
18
19
|
import { GridCellEditStartReasons, GridCellEditStopReasons } from '../../../models/params/gridEditCellParams';
|
|
19
20
|
var missingOnProcessRowUpdateErrorWarning = buildWarning(['MUI: A call to `processRowUpdate` threw an error which was not handled because `onProcessRowUpdateError` is missing.', 'To handle the error pass a callback to the `onProcessRowUpdateError` prop, e.g. `<DataGrid onProcessRowUpdateError={(error) => ...} />`.', 'For more detail, see http://mui.com/components/data-grid/editing/#persistence.'], 'error');
|
|
20
21
|
export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
|
|
@@ -315,16 +316,20 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
|
|
|
315
316
|
_editingState$id$fiel = editingState[id][field], error = _editingState$id$fiel.error, isProcessingProps = _editingState$id$fiel.isProcessingProps;
|
|
316
317
|
|
|
317
318
|
if (!(error || isProcessingProps)) {
|
|
318
|
-
_context.next =
|
|
319
|
+
_context.next = 13;
|
|
319
320
|
break;
|
|
320
321
|
}
|
|
321
322
|
|
|
322
323
|
// Attempt to change cell mode to "view" was not successful
|
|
323
324
|
// Update previous mode to allow another attempt
|
|
324
|
-
prevCellModesModel.current[id][field].mode = GridCellModes.Edit;
|
|
325
|
+
prevCellModesModel.current[id][field].mode = GridCellModes.Edit; // Revert the mode in the cellModesModel prop back to "edit"
|
|
326
|
+
|
|
327
|
+
updateFieldInCellModesModel(id, field, {
|
|
328
|
+
mode: GridCellModes.Edit
|
|
329
|
+
});
|
|
325
330
|
return _context.abrupt("return");
|
|
326
331
|
|
|
327
|
-
case
|
|
332
|
+
case 13:
|
|
328
333
|
rowUpdate = apiRef.current.unstable_getRowWithUpdatedValuesFromCellEditing(id, field);
|
|
329
334
|
|
|
330
335
|
if (processRowUpdate) {
|
|
@@ -352,7 +357,7 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
|
|
|
352
357
|
finishCellEditMode();
|
|
353
358
|
}
|
|
354
359
|
|
|
355
|
-
case
|
|
360
|
+
case 15:
|
|
356
361
|
case "end":
|
|
357
362
|
return _context.stop();
|
|
358
363
|
}
|
|
@@ -470,7 +475,8 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
|
|
|
470
475
|
var idToIdLookup = gridRowsIdToIdLookupSelector(apiRef); // Update the ref here because updateStateToStopCellEditMode may change it later
|
|
471
476
|
|
|
472
477
|
var copyOfPrevCellModes = prevCellModesModel.current;
|
|
473
|
-
prevCellModesModel.current = cellModesModel;
|
|
478
|
+
prevCellModesModel.current = deepClone(cellModesModel); // Do a deep-clone because the attributes might be changed later
|
|
479
|
+
|
|
474
480
|
Object.entries(cellModesModel).forEach(function (_ref3) {
|
|
475
481
|
var _ref4 = _slicedToArray(_ref3, 2),
|
|
476
482
|
id = _ref4[0],
|
|
@@ -14,6 +14,7 @@ import { isPrintableKey } from '../../../utils/keyboardUtils';
|
|
|
14
14
|
import { gridColumnFieldsSelector } from '../columns/gridColumnsSelector';
|
|
15
15
|
import { buildWarning } from '../../../utils/warning';
|
|
16
16
|
import { gridRowsIdToIdLookupSelector } from '../rows/gridRowsSelector';
|
|
17
|
+
import { deepClone } from '../../../utils/utils';
|
|
17
18
|
import { GridRowEditStopReasons, GridRowEditStartReasons } from '../../../models/params/gridRowParams';
|
|
18
19
|
var missingOnProcessRowUpdateErrorWarning = buildWarning(['MUI: A call to `processRowUpdate` threw an error which was not handled because `onProcessRowUpdateError` is missing.', 'To handle the error pass a callback to the `onProcessRowUpdateError` prop, e.g. `<DataGrid onProcessRowUpdateError={(error) => ...} />`.', 'For more detail, see http://mui.com/components/data-grid/editing/#persistence.'], 'error');
|
|
19
20
|
export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
|
|
@@ -402,7 +403,11 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
|
|
|
402
403
|
});
|
|
403
404
|
|
|
404
405
|
if (hasSomeFieldWithError) {
|
|
405
|
-
prevRowModesModel.current[id].mode = GridRowModes.Edit;
|
|
406
|
+
prevRowModesModel.current[id].mode = GridRowModes.Edit; // Revert the mode in the rowModesModel prop back to "edit"
|
|
407
|
+
|
|
408
|
+
updateRowInRowModesModel(id, {
|
|
409
|
+
mode: GridRowModes.Edit
|
|
410
|
+
});
|
|
406
411
|
return;
|
|
407
412
|
}
|
|
408
413
|
|
|
@@ -593,7 +598,8 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
|
|
|
593
598
|
var idToIdLookup = gridRowsIdToIdLookupSelector(apiRef); // Update the ref here because updateStateToStopRowEditMode may change it later
|
|
594
599
|
|
|
595
600
|
var copyOfPrevRowModesModel = prevRowModesModel.current;
|
|
596
|
-
prevRowModesModel.current = rowModesModel;
|
|
601
|
+
prevRowModesModel.current = deepClone(rowModesModel); // Do a deep-clone because the attributes might be changed later
|
|
602
|
+
|
|
597
603
|
Object.entries(rowModesModel).forEach(function (_ref5) {
|
|
598
604
|
var _copyOfPrevRowModesMo, _idToIdLookup$id;
|
|
599
605
|
|
package/legacy/index.js
CHANGED
package/legacy/utils/utils.js
CHANGED
|
@@ -198,4 +198,11 @@ export function randomNumberBetween(seed, min, max) {
|
|
|
198
198
|
return function () {
|
|
199
199
|
return min + (max - min) * random();
|
|
200
200
|
};
|
|
201
|
+
}
|
|
202
|
+
export function deepClone(obj) {
|
|
203
|
+
if (typeof structuredClone === 'function') {
|
|
204
|
+
return structuredClone(obj);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
return JSON.parse(JSON.stringify(obj));
|
|
201
208
|
}
|
|
@@ -11,6 +11,7 @@ import { gridEditRowsStateSelector } from './gridEditRowsSelector';
|
|
|
11
11
|
import { isPrintableKey } from '../../../utils/keyboardUtils';
|
|
12
12
|
import { buildWarning } from '../../../utils/warning';
|
|
13
13
|
import { gridRowsIdToIdLookupSelector } from '../rows/gridRowsSelector';
|
|
14
|
+
import { deepClone } from '../../../utils/utils';
|
|
14
15
|
import { GridCellEditStartReasons, GridCellEditStopReasons } from '../../../models/params/gridEditCellParams';
|
|
15
16
|
const missingOnProcessRowUpdateErrorWarning = buildWarning(['MUI: A call to `processRowUpdate` threw an error which was not handled because `onProcessRowUpdateError` is missing.', 'To handle the error pass a callback to the `onProcessRowUpdateError` prop, e.g. `<DataGrid onProcessRowUpdateError={(error) => ...} />`.', 'For more detail, see http://mui.com/components/data-grid/editing/#persistence.'], 'error');
|
|
16
17
|
export const useGridCellEditing = (apiRef, props) => {
|
|
@@ -319,7 +320,11 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
319
320
|
if (error || isProcessingProps) {
|
|
320
321
|
// Attempt to change cell mode to "view" was not successful
|
|
321
322
|
// Update previous mode to allow another attempt
|
|
322
|
-
prevCellModesModel.current[id][field].mode = GridCellModes.Edit;
|
|
323
|
+
prevCellModesModel.current[id][field].mode = GridCellModes.Edit; // Revert the mode in the cellModesModel prop back to "edit"
|
|
324
|
+
|
|
325
|
+
updateFieldInCellModesModel(id, field, {
|
|
326
|
+
mode: GridCellModes.Edit
|
|
327
|
+
});
|
|
323
328
|
return;
|
|
324
329
|
}
|
|
325
330
|
|
|
@@ -435,7 +440,8 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
435
440
|
const idToIdLookup = gridRowsIdToIdLookupSelector(apiRef); // Update the ref here because updateStateToStopCellEditMode may change it later
|
|
436
441
|
|
|
437
442
|
const copyOfPrevCellModes = prevCellModesModel.current;
|
|
438
|
-
prevCellModesModel.current = cellModesModel;
|
|
443
|
+
prevCellModesModel.current = deepClone(cellModesModel); // Do a deep-clone because the attributes might be changed later
|
|
444
|
+
|
|
439
445
|
Object.entries(cellModesModel).forEach(([id, fields]) => {
|
|
440
446
|
Object.entries(fields).forEach(([field, params]) => {
|
|
441
447
|
const prevMode = copyOfPrevCellModes[id]?.[field]?.mode || GridCellModes.View;
|
|
@@ -12,6 +12,7 @@ import { isPrintableKey } from '../../../utils/keyboardUtils';
|
|
|
12
12
|
import { gridColumnFieldsSelector } from '../columns/gridColumnsSelector';
|
|
13
13
|
import { buildWarning } from '../../../utils/warning';
|
|
14
14
|
import { gridRowsIdToIdLookupSelector } from '../rows/gridRowsSelector';
|
|
15
|
+
import { deepClone } from '../../../utils/utils';
|
|
15
16
|
import { GridRowEditStopReasons, GridRowEditStartReasons } from '../../../models/params/gridRowParams';
|
|
16
17
|
const missingOnProcessRowUpdateErrorWarning = buildWarning(['MUI: A call to `processRowUpdate` threw an error which was not handled because `onProcessRowUpdateError` is missing.', 'To handle the error pass a callback to the `onProcessRowUpdateError` prop, e.g. `<DataGrid onProcessRowUpdateError={(error) => ...} />`.', 'For more detail, see http://mui.com/components/data-grid/editing/#persistence.'], 'error');
|
|
17
18
|
export const useGridRowEditing = (apiRef, props) => {
|
|
@@ -401,7 +402,11 @@ export const useGridRowEditing = (apiRef, props) => {
|
|
|
401
402
|
const hasSomeFieldWithError = Object.values(editingState[id]).some(fieldProps => fieldProps.error);
|
|
402
403
|
|
|
403
404
|
if (hasSomeFieldWithError) {
|
|
404
|
-
prevRowModesModel.current[id].mode = GridRowModes.Edit;
|
|
405
|
+
prevRowModesModel.current[id].mode = GridRowModes.Edit; // Revert the mode in the rowModesModel prop back to "edit"
|
|
406
|
+
|
|
407
|
+
updateRowInRowModesModel(id, {
|
|
408
|
+
mode: GridRowModes.Edit
|
|
409
|
+
});
|
|
405
410
|
return;
|
|
406
411
|
}
|
|
407
412
|
|
|
@@ -584,7 +589,8 @@ export const useGridRowEditing = (apiRef, props) => {
|
|
|
584
589
|
const idToIdLookup = gridRowsIdToIdLookupSelector(apiRef); // Update the ref here because updateStateToStopRowEditMode may change it later
|
|
585
590
|
|
|
586
591
|
const copyOfPrevRowModesModel = prevRowModesModel.current;
|
|
587
|
-
prevRowModesModel.current = rowModesModel;
|
|
592
|
+
prevRowModesModel.current = deepClone(rowModesModel); // Do a deep-clone because the attributes might be changed later
|
|
593
|
+
|
|
588
594
|
Object.entries(rowModesModel).forEach(([id, params]) => {
|
|
589
595
|
const prevMode = copyOfPrevRowModesModel[id]?.mode || GridRowModes.View;
|
|
590
596
|
const originalId = idToIdLookup[id] ?? id;
|
package/modern/index.js
CHANGED
package/modern/utils/utils.js
CHANGED
|
@@ -193,4 +193,11 @@ function mulberry32(a) {
|
|
|
193
193
|
export function randomNumberBetween(seed, min, max) {
|
|
194
194
|
const random = mulberry32(seed);
|
|
195
195
|
return () => min + (max - min) * random();
|
|
196
|
+
}
|
|
197
|
+
export function deepClone(obj) {
|
|
198
|
+
if (typeof structuredClone === 'function') {
|
|
199
|
+
return structuredClone(obj);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return JSON.parse(JSON.stringify(obj));
|
|
196
203
|
}
|
|
@@ -29,6 +29,8 @@ var _warning = require("../../../utils/warning");
|
|
|
29
29
|
|
|
30
30
|
var _gridRowsSelector = require("../rows/gridRowsSelector");
|
|
31
31
|
|
|
32
|
+
var _utils = require("../../../utils/utils");
|
|
33
|
+
|
|
32
34
|
var _gridEditCellParams = require("../../../models/params/gridEditCellParams");
|
|
33
35
|
|
|
34
36
|
const _excluded = ["id", "field"],
|
|
@@ -339,7 +341,11 @@ const useGridCellEditing = (apiRef, props) => {
|
|
|
339
341
|
if (error || isProcessingProps) {
|
|
340
342
|
// Attempt to change cell mode to "view" was not successful
|
|
341
343
|
// Update previous mode to allow another attempt
|
|
342
|
-
prevCellModesModel.current[id][field].mode = _gridEditRowModel.GridCellModes.Edit;
|
|
344
|
+
prevCellModesModel.current[id][field].mode = _gridEditRowModel.GridCellModes.Edit; // Revert the mode in the cellModesModel prop back to "edit"
|
|
345
|
+
|
|
346
|
+
updateFieldInCellModesModel(id, field, {
|
|
347
|
+
mode: _gridEditRowModel.GridCellModes.Edit
|
|
348
|
+
});
|
|
343
349
|
return;
|
|
344
350
|
}
|
|
345
351
|
|
|
@@ -456,7 +462,8 @@ const useGridCellEditing = (apiRef, props) => {
|
|
|
456
462
|
const idToIdLookup = (0, _gridRowsSelector.gridRowsIdToIdLookupSelector)(apiRef); // Update the ref here because updateStateToStopCellEditMode may change it later
|
|
457
463
|
|
|
458
464
|
const copyOfPrevCellModes = prevCellModesModel.current;
|
|
459
|
-
prevCellModesModel.current = cellModesModel;
|
|
465
|
+
prevCellModesModel.current = (0, _utils.deepClone)(cellModesModel); // Do a deep-clone because the attributes might be changed later
|
|
466
|
+
|
|
460
467
|
Object.entries(cellModesModel).forEach(([id, fields]) => {
|
|
461
468
|
Object.entries(fields).forEach(([field, params]) => {
|
|
462
469
|
var _copyOfPrevCellModes$, _copyOfPrevCellModes$2, _idToIdLookup$id;
|
|
@@ -31,6 +31,8 @@ var _warning = require("../../../utils/warning");
|
|
|
31
31
|
|
|
32
32
|
var _gridRowsSelector = require("../rows/gridRowsSelector");
|
|
33
33
|
|
|
34
|
+
var _utils = require("../../../utils/utils");
|
|
35
|
+
|
|
34
36
|
var _gridRowParams = require("../../../models/params/gridRowParams");
|
|
35
37
|
|
|
36
38
|
const _excluded = ["id"],
|
|
@@ -421,7 +423,11 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
421
423
|
const hasSomeFieldWithError = Object.values(editingState[id]).some(fieldProps => fieldProps.error);
|
|
422
424
|
|
|
423
425
|
if (hasSomeFieldWithError) {
|
|
424
|
-
prevRowModesModel.current[id].mode = _gridEditRowModel.GridRowModes.Edit;
|
|
426
|
+
prevRowModesModel.current[id].mode = _gridEditRowModel.GridRowModes.Edit; // Revert the mode in the rowModesModel prop back to "edit"
|
|
427
|
+
|
|
428
|
+
updateRowInRowModesModel(id, {
|
|
429
|
+
mode: _gridEditRowModel.GridRowModes.Edit
|
|
430
|
+
});
|
|
425
431
|
return;
|
|
426
432
|
}
|
|
427
433
|
|
|
@@ -597,7 +603,8 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
597
603
|
const idToIdLookup = (0, _gridRowsSelector.gridRowsIdToIdLookupSelector)(apiRef); // Update the ref here because updateStateToStopRowEditMode may change it later
|
|
598
604
|
|
|
599
605
|
const copyOfPrevRowModesModel = prevRowModesModel.current;
|
|
600
|
-
prevRowModesModel.current = rowModesModel;
|
|
606
|
+
prevRowModesModel.current = (0, _utils.deepClone)(rowModesModel); // Do a deep-clone because the attributes might be changed later
|
|
607
|
+
|
|
601
608
|
Object.entries(rowModesModel).forEach(([id, params]) => {
|
|
602
609
|
var _copyOfPrevRowModesMo, _idToIdLookup$id;
|
|
603
610
|
|
package/node/index.js
CHANGED
package/node/utils/utils.js
CHANGED
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.clamp = void 0;
|
|
7
|
+
exports.deepClone = deepClone;
|
|
7
8
|
exports.escapeRegExp = escapeRegExp;
|
|
8
9
|
exports.isDeepEqual = isDeepEqual;
|
|
9
10
|
exports.isFunction = isFunction;
|
|
@@ -216,4 +217,12 @@ function mulberry32(a) {
|
|
|
216
217
|
function randomNumberBetween(seed, min, max) {
|
|
217
218
|
const random = mulberry32(seed);
|
|
218
219
|
return () => min + (max - min) * random();
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function deepClone(obj) {
|
|
223
|
+
if (typeof structuredClone === 'function') {
|
|
224
|
+
return structuredClone(obj);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
return JSON.parse(JSON.stringify(obj));
|
|
219
228
|
}
|
package/package.json
CHANGED
package/utils/utils.d.ts
CHANGED
|
@@ -36,3 +36,4 @@ export declare const clamp: (value: number, min: number, max: number) => number;
|
|
|
36
36
|
*/
|
|
37
37
|
export declare function isDeepEqual<T>(actual: any, expected: T): actual is T;
|
|
38
38
|
export declare function randomNumberBetween(seed: number, min: number, max: number): () => number;
|
|
39
|
+
export declare function deepClone(obj: Record<string, any>): any;
|
package/utils/utils.js
CHANGED
|
@@ -193,4 +193,11 @@ function mulberry32(a) {
|
|
|
193
193
|
export function randomNumberBetween(seed, min, max) {
|
|
194
194
|
const random = mulberry32(seed);
|
|
195
195
|
return () => min + (max - min) * random();
|
|
196
|
+
}
|
|
197
|
+
export function deepClone(obj) {
|
|
198
|
+
if (typeof structuredClone === 'function') {
|
|
199
|
+
return structuredClone(obj);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return JSON.parse(JSON.stringify(obj));
|
|
196
203
|
}
|