Skip to content

Commit e601e20

Browse files
Alyar666sjbur
authored andcommitted
DataGrid: Fix focus getting stuck on Save button when columnRenderingMode is virtual (T1326106) (DevExpress#33201)
Co-authored-by: Alyar <>
1 parent 645cf99 commit e601e20

7 files changed

Lines changed: 330 additions & 167 deletions

File tree

e2e/testcafe-devextreme/tests/dataGrid/common/keyboardNavigation/virtualColumns.functional.ts

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,3 +321,137 @@ test('DataGrid should scroll to the last cell of the previous row and focus it w
321321
}));
322322
});
323323
});
324+
325+
test('DataGrid should move focus from Save to Cancel button on Tab press in row editing mode with virtual columns (T1326106)', async (t) => {
326+
// arrange
327+
const dataGrid = new DataGrid('#container');
328+
329+
await t
330+
.expect(dataGrid.isReady())
331+
.ok();
332+
333+
const commandCell = dataGrid.getDataRow(0).getCommandCell(5);
334+
335+
// act - click Edit button on first row
336+
await t.click(commandCell.getButton(0));
337+
338+
const saveButton = commandCell.getButton(0);
339+
const cancelButton = commandCell.getButton(1);
340+
341+
// assert
342+
await t
343+
.expect(saveButton.exists)
344+
.ok()
345+
.expect(cancelButton.exists)
346+
.ok();
347+
348+
const lastDataCell = dataGrid.getDataCell(0, 4);
349+
350+
// act
351+
await t.click(lastDataCell.element);
352+
353+
// assert
354+
await t
355+
.expect(lastDataCell.isFocused)
356+
.ok();
357+
358+
// act
359+
await t.pressKey('tab');
360+
361+
// assert
362+
await t
363+
.expect(saveButton.focused)
364+
.ok();
365+
366+
// act
367+
await t.pressKey('tab');
368+
369+
// assert
370+
await t
371+
.expect(cancelButton.focused)
372+
.ok();
373+
374+
// act
375+
await t.pressKey('tab');
376+
377+
// assert - First cell of the second row should be focused
378+
await t
379+
.expect(dataGrid.getDataCell(1, 0).isFocused)
380+
.ok();
381+
}).before(async () => createWidget('dxDataGrid', {
382+
width: 800,
383+
dataSource: generateData(10, 5),
384+
columnWidth: 100,
385+
keyExpr: 'field1',
386+
editing: {
387+
mode: 'row',
388+
allowUpdating: true,
389+
allowDeleting: true,
390+
},
391+
scrolling: {
392+
columnRenderingMode: 'virtual',
393+
},
394+
}));
395+
396+
test('DataGrid should move focus from Save button to the last data cell on Shift + Tab press in row editing mode(T1326106)', async (t) => {
397+
// arrange
398+
const dataGrid = new DataGrid('#container');
399+
400+
await t
401+
.expect(dataGrid.isReady())
402+
.ok();
403+
404+
const commandCell = dataGrid.getDataRow(0).getCommandCell(5);
405+
406+
// act - click Edit button on first row
407+
await t.click(commandCell.getButton(0));
408+
409+
const saveButton = commandCell.getButton(0);
410+
const cancelButton = commandCell.getButton(1);
411+
412+
// assert
413+
await t
414+
.expect(saveButton.exists)
415+
.ok()
416+
.expect(cancelButton.exists)
417+
.ok();
418+
419+
const firstDataCell = dataGrid.getDataCell(1, 0);
420+
421+
// act
422+
await t.click(firstDataCell.element);
423+
424+
// assert
425+
await t
426+
.expect(firstDataCell.element.focused)
427+
.ok();
428+
429+
// act
430+
await t.pressKey('shift+tab');
431+
432+
// assert
433+
await t
434+
.expect(saveButton.focused)
435+
.ok();
436+
437+
// act
438+
await t.pressKey('shift+tab');
439+
440+
// assert - Last cell of the first row should be focused
441+
await t
442+
.expect(dataGrid.getDataCell(0, 4).isFocused)
443+
.ok();
444+
}).before(async () => createWidget('dxDataGrid', {
445+
width: 800,
446+
dataSource: generateData(10, 5),
447+
columnWidth: 100,
448+
keyExpr: 'field1',
449+
editing: {
450+
mode: 'row',
451+
allowUpdating: true,
452+
allowDeleting: true,
453+
},
454+
scrolling: {
455+
columnRenderingMode: 'virtual',
456+
},
457+
}));

packages/devextreme/js/__internal/grids/grid_core/adaptivity/m_adaptivity.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,6 @@ function focusCellHandler(e) {
102102
}
103103

104104
export class AdaptiveColumnsController extends modules.ViewController {
105-
private _keyboardNavigationController!: KeyboardNavigationController;
106-
107105
private _columnsController!: ColumnsController;
108106

109107
private _dataController!: DataController;
@@ -120,6 +118,8 @@ export class AdaptiveColumnsController extends modules.ViewController {
120118

121119
private _hidingColumnsQueue: any;
122120

121+
protected _keyboardNavigationController!: KeyboardNavigationController;
122+
123123
public init() {
124124
this._columnsController = this.getController('columns');
125125
this._dataController = this.getController('data');

0 commit comments

Comments
 (0)