Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataGrid - The "Cannot read properties of undefined error" occurs when using Tab while saving a promise (T1190566) #28695

Open
wants to merge 2 commits into
base: 24_2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 35 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,41 @@ test('Focused cell should be switched to the editing mode after onSaving\'s prom
});
});

test('DataGrid - The "Cannot read properties of undefined error" occurs when using Tab while saving a promise (T1190566)', 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
Loading