Skip to content

Commit 0274499

Browse files
authored
DataGrid - The "Cannot read properties of undefined error" occurs when using Tab while saving a promise (T1190566) (DevExpress#28696)
1 parent 19ab6e9 commit 0274499

File tree

2 files changed

+36
-4
lines changed

2 files changed

+36
-4
lines changed

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

Lines changed: 35 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,41 @@ test('Focused cell should be switched to the editing mode after onSaving\'s prom
10198
});
10299
});
103100

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

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)