Skip to content

Commit

Permalink
DataGrid - The "Cannot read properties of undefined error" occurs whe…
Browse files Browse the repository at this point in the history
…n using Tab while saving a promise (#28660)
  • Loading branch information
tongsonbarbs committed Jan 10, 2025
1 parent 7835111 commit 46f1357
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
39 changes: 36 additions & 3 deletions e2e/testcafe-devextreme/tests/dataGrid/editing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,11 @@ test('Focused cell should be switched to the editing mode after onSaving\'s prom
const dataGrid = new DataGrid('#container');
const resolveOnSavingDeferred = ClientFunction(() => (window as any).deferred.resolve());

// act
await t
.click(dataGrid.getDataCell(0, 0).element)
.typeText(dataGrid.getDataCell(0, 0).element, 'new_value')
.pressKey('tab tab');
await resolveOnSavingDeferred();

// assert
await t.expect(dataGrid.getDataCell(2, 0).isEditCell).ok();
}).before(async () => {
await ClientFunction(() => {
Expand All @@ -101,6 +98,42 @@ test('Focused cell should be switched to the editing mode after onSaving\'s prom
});
});

// T1190566
test('DataGrid - The "Cannot read properties of undefined error" occurs when using Tab while saving a promise', async (t) => {
const dataGrid = new DataGrid('#container');
const resolveOnSavingDeferred = ClientFunction(() => (window as any).deferred.resolve());

await t
.click(dataGrid.getDataCell(0, 0).element)
.typeText(dataGrid.getDataCell(0, 0).element, 'new_value')
.pressKey('enter tab tab');
await resolveOnSavingDeferred();
await t.expect(dataGrid.getDataCell(2, 0).isFocused).ok();
}).before(async () => {
await ClientFunction(() => {
(window as any).deferred = $.Deferred();
})();

return createWidget('dxDataGrid', {
dataSource: [
{ id: 1, field1: 'value1' },
{ id: 2, field1: 'value2' },
{ id: 3, field1: 'value3' },
{ id: 4, field1: 'value4' },
],
keyExpr: 'id',
showBorders: true,
columns: ['field1'],
editing: {
mode: 'cell',
allowUpdating: true,
},
onSaving(e) {
e.promise = (window as any).deferred;
},
});
});

test('Tab key on editor should focus next cell if editing mode is cell', async (t) => {
const dataGrid = new DataGrid('#container');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ export const validatingEditingExtender = (Base: ModuleType<EditingController>) =
// eslint-disable-next-line @typescript-eslint/no-unused-vars
protected _beforeSaveEditData(change, editIndex?) {
let result: any = super._beforeSaveEditData.apply(this, arguments as any);
const validationData = this._validatingController._getValidationData(change?.key);
const validationData = this._validatingController._getValidationData(change?.key, true);

if (change) {
const isValid = change.type === 'remove' || validationData.isValid;
Expand Down

0 comments on commit 46f1357

Please sign in to comment.