From 929212f26b3a6e6005025446f4b433aba0fbfb65 Mon Sep 17 00:00:00 2001 From: "anna.shakhova" Date: Wed, 24 Jun 2026 10:03:15 +0200 Subject: [PATCH] GridCore: fix focus anchor when leave 1st cell with Shift+Tab --- .../keyboardNavigation.functional.ts | 30 +++++++++++++++++++ .../m_keyboard_navigation.ts | 3 ++ 2 files changed, 33 insertions(+) diff --git a/e2e/testcafe-devextreme/tests/dataGrid/common/keyboardNavigation/keyboardNavigation.functional.ts b/e2e/testcafe-devextreme/tests/dataGrid/common/keyboardNavigation/keyboardNavigation.functional.ts index cca663e01234..b96b6e0044ee 100644 --- a/e2e/testcafe-devextreme/tests/dataGrid/common/keyboardNavigation/keyboardNavigation.functional.ts +++ b/e2e/testcafe-devextreme/tests/dataGrid/common/keyboardNavigation/keyboardNavigation.functional.ts @@ -1869,6 +1869,36 @@ test('The expand cell should not lose focus on expanding a master row (T892203)' }, columns: ['a', 'b'], })); + + test(`${editMode} mode - Shift+Tab from the first editable cell should move focus to the last header (T1329750)`, async (t) => { + const dataGrid = new DataGrid('#container') as any; + const cell00 = dataGrid.getDataCell(0, 0); + const editor00 = cell00.getEditor(); + const lastHeaderCell = dataGrid.getHeaders().getHeaderRow(0).getHeaderCell(1); + + await t.expect(dataGrid.isReady()).ok(); + + await t + .click(cell00.element) + + .expect(cell00.isFocused).ok() + .expect(editor00.element.focused) + .ok() + + .pressKey('shift+tab') + + .expect(cell00.isFocused) + .notOk() + .expect(lastHeaderCell.element.focused) + .ok(); + }).before(async () => createWidget('dxDataGrid', { + dataSource: [{ a: '1', b: '2' }], + editing: { + mode: editMode.toLowerCase() as any, + allowUpdating: true, + }, + columns: ['a', 'b'], + })); }); test('Horizontal moving by keydown if scrolling.columnRenderingMode: virtual', async (t) => { diff --git a/packages/devextreme/js/__internal/grids/grid_core/keyboard_navigation/m_keyboard_navigation.ts b/packages/devextreme/js/__internal/grids/grid_core/keyboard_navigation/m_keyboard_navigation.ts index 9523256f5095..efb84dda154d 100644 --- a/packages/devextreme/js/__internal/grids/grid_core/keyboard_navigation/m_keyboard_navigation.ts +++ b/packages/devextreme/js/__internal/grids/grid_core/keyboard_navigation/m_keyboard_navigation.ts @@ -508,6 +508,9 @@ export class KeyboardNavigationController extends KeyboardNavigationControllerCo this._editorFactory.loseFocus(); if (this._editingController.isEditing() && !this.isRowEditMode()) { + // Focus the cell before closing the editor on native Tab-out, + // so the browser's native Shift+Tab leaves from a stable anchor. + ($cell.get(0) as HTMLElement | undefined)?.focus({ preventScroll: true }); this._resetFocusedCell(true); this._resetFocusedView(); this._closeEditCell();