Skip to content

Commit b55e5b6

Browse files
authored
DataGrid - The "Cannot read properties of undefined error" occurs when using Tab while saving a promise (#28660)
1 parent c7dc0e1 commit b55e5b6

File tree

2 files changed

+37
-4
lines changed

2 files changed

+37
-4
lines changed

e2e/testcafe-devextreme/tests/dataGrid/editing.ts

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,11 @@ test('Focused cell should be switched to the editing mode after onSaving\'s prom
6767
const dataGrid = new DataGrid('#container');
6868
const resolveOnSavingDeferred = ClientFunction(() => (window as any).deferred.resolve());
6969

70-
// act
7170
await t
7271
.click(dataGrid.getDataCell(0, 0).element)
7372
.typeText(dataGrid.getDataCell(0, 0).element, 'new_value')
7473
.pressKey('tab tab');
7574
await resolveOnSavingDeferred();
76-
77-
// assert
7875
await t.expect(dataGrid.getDataCell(2, 0).isEditCell).ok();
7976
}).before(async () => {
8077
await ClientFunction(() => {
@@ -101,6 +98,42 @@ test('Focused cell should be switched to the editing mode after onSaving\'s prom
10198
});
10299
});
103100

101+
// T1190566
102+
test('DataGrid - The "Cannot read properties of undefined error" occurs when using Tab while saving a promise', async (t) => {
103+
const dataGrid = new DataGrid('#container');
104+
const resolveOnSavingDeferred = ClientFunction(() => (window as any).deferred.resolve());
105+
106+
await t
107+
.click(dataGrid.getDataCell(0, 0).element)
108+
.typeText(dataGrid.getDataCell(0, 0).element, 'new_value')
109+
.pressKey('enter tab tab');
110+
await resolveOnSavingDeferred();
111+
await t.expect(dataGrid.getDataCell(2, 0).isFocused).ok();
112+
}).before(async () => {
113+
await ClientFunction(() => {
114+
(window as any).deferred = $.Deferred();
115+
})();
116+
117+
return createWidget('dxDataGrid', {
118+
dataSource: [
119+
{ id: 1, field1: 'value1' },
120+
{ id: 2, field1: 'value2' },
121+
{ id: 3, field1: 'value3' },
122+
{ id: 4, field1: 'value4' },
123+
],
124+
keyExpr: 'id',
125+
showBorders: true,
126+
columns: ['field1'],
127+
editing: {
128+
mode: 'cell',
129+
allowUpdating: true,
130+
},
131+
onSaving(e) {
132+
e.promise = (window as any).deferred;
133+
},
134+
});
135+
});
136+
104137
test('Tab key on editor should focus next cell if editing mode is cell', async (t) => {
105138
const dataGrid = new DataGrid('#container');
106139

packages/devextreme/js/__internal/grids/grid_core/validating/m_validating.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@ export const validatingEditingExtender = (Base: ModuleType<EditingController>) =
844844
// eslint-disable-next-line @typescript-eslint/no-unused-vars
845845
protected _beforeSaveEditData(change, editIndex?) {
846846
let result: any = super._beforeSaveEditData.apply(this, arguments as any);
847-
const validationData = this._validatingController._getValidationData(change?.key);
847+
const validationData = this._validatingController._getValidationData(change?.key, true);
848848

849849
if (change) {
850850
const isValid = change.type === 'remove' || validationData.isValid;

0 commit comments

Comments
 (0)