Skip to content

Commit 76b64ca

Browse files
GridCore: fix focus anchor when leave 1st cell with Shift+Tab (T1329750) (#34119)
1 parent e3a00c6 commit 76b64ca

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1869,6 +1869,36 @@ test('The expand cell should not lose focus on expanding a master row (T892203)'
18691869
},
18701870
columns: ['a', 'b'],
18711871
}));
1872+
1873+
test(`${editMode} mode - Shift+Tab from the first editable cell should move focus to the last header (T1329750)`, async (t) => {
1874+
const dataGrid = new DataGrid('#container') as any;
1875+
const cell00 = dataGrid.getDataCell(0, 0);
1876+
const editor00 = cell00.getEditor();
1877+
const lastHeaderCell = dataGrid.getHeaders().getHeaderRow(0).getHeaderCell(1);
1878+
1879+
await t.expect(dataGrid.isReady()).ok();
1880+
1881+
await t
1882+
.click(cell00.element)
1883+
1884+
.expect(cell00.isFocused).ok()
1885+
.expect(editor00.element.focused)
1886+
.ok()
1887+
1888+
.pressKey('shift+tab')
1889+
1890+
.expect(cell00.isFocused)
1891+
.notOk()
1892+
.expect(lastHeaderCell.element.focused)
1893+
.ok();
1894+
}).before(async () => createWidget('dxDataGrid', {
1895+
dataSource: [{ a: '1', b: '2' }],
1896+
editing: {
1897+
mode: editMode.toLowerCase() as any,
1898+
allowUpdating: true,
1899+
},
1900+
columns: ['a', 'b'],
1901+
}));
18721902
});
18731903

18741904
test('Horizontal moving by keydown if scrolling.columnRenderingMode: virtual', async (t) => {

packages/devextreme/js/__internal/grids/grid_core/keyboard_navigation/m_keyboard_navigation.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,9 @@ export class KeyboardNavigationController extends KeyboardNavigationControllerCo
508508
this._editorFactory.loseFocus();
509509

510510
if (this._editingController.isEditing() && !this.isRowEditMode()) {
511+
// Focus the cell before closing the editor on native Tab-out,
512+
// so the browser's native Shift+Tab leaves from a stable anchor.
513+
($cell.get(0) as HTMLElement | undefined)?.focus({ preventScroll: true });
511514
this._resetFocusedCell(true);
512515
this._resetFocusedView();
513516
this._closeEditCell();

0 commit comments

Comments
 (0)