Skip to content

Commit 6375097

Browse files
authored
DataGrid: Fix header focus not restoring when multiple grouping applied (T1325775) (#33209)
1 parent 046ec96 commit 6375097

6 files changed

Lines changed: 358 additions & 164 deletions

File tree

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

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1340,6 +1340,90 @@ test('Tab key on the focused group row should be handled by default behavior (T8
13401340
});
13411341
});
13421342

1343+
test('DataGrid - Focus should move back to headers on Shift+Tab when multiple grouping is applied (T1325775)', async (t) => {
1344+
const dataGrid = new DataGrid('#container');
1345+
const headerRow = dataGrid.getHeaders().getHeaderRow(0);
1346+
const headerCell = headerRow.getHeaderCell(2);
1347+
const stateGroupRow = dataGrid.getGroupRow(0);
1348+
const cityGroupRow = dataGrid.getGroupRow(1);
1349+
const firstDataCell = dataGrid.getDataCell(2, 2);
1350+
1351+
await t
1352+
.expect(dataGrid.isReady())
1353+
.ok();
1354+
1355+
await addFocusableElementBefore('#container');
1356+
1357+
await t
1358+
.click(Selector('#focusable-start'))
1359+
.pressKey('tab')
1360+
.expect(headerCell.isFocused)
1361+
.ok()
1362+
1363+
.pressKey('tab')
1364+
.expect(stateGroupRow.isFocused)
1365+
.ok()
1366+
1367+
.pressKey('tab')
1368+
.expect(cityGroupRow.isFocused)
1369+
.ok()
1370+
1371+
.pressKey('tab')
1372+
.expect(firstDataCell.isFocused)
1373+
.ok()
1374+
1375+
.pressKey('shift+tab')
1376+
.expect(cityGroupRow.isFocused)
1377+
.ok()
1378+
1379+
.pressKey('shift+tab')
1380+
.expect(stateGroupRow.isFocused)
1381+
.ok()
1382+
1383+
.pressKey('shift+tab')
1384+
.expect(headerCell.isFocused)
1385+
.ok();
1386+
}).before(async () => {
1387+
await createWidget('dxDataGrid', {
1388+
showBorders: true,
1389+
keyExpr: 'id',
1390+
dataSource: [
1391+
{
1392+
id: 1,
1393+
state: 'Arkansas',
1394+
city: 'Bentonville',
1395+
company: 'Super Mart of the West',
1396+
},
1397+
{
1398+
id: 2,
1399+
state: 'Arkansas',
1400+
city: 'Bentonville',
1401+
company: 'Electronics Depot',
1402+
},
1403+
{
1404+
id: 3,
1405+
state: 'California',
1406+
city: 'Cupertino',
1407+
company: 'Braeburn',
1408+
},
1409+
],
1410+
grouping: {
1411+
autoExpandAll: true,
1412+
},
1413+
columns: [
1414+
{
1415+
dataField: 'state',
1416+
groupIndex: 0,
1417+
},
1418+
{
1419+
dataField: 'city',
1420+
groupIndex: 1,
1421+
},
1422+
'company',
1423+
],
1424+
});
1425+
});
1426+
13431427
test('Row should not be focused by "focusedRowIndex" after change "pageIndex" by pager if "autoNavigateToFocused" row is false', async (t) => {
13441428
const dataGrid = new DataGrid('#container');
13451429
await t

packages/devextreme/js/__internal/grids/grid_core/focus/m_focus.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ const keyboardNavigation = (Base: ModuleType<KeyboardNavigationController>) => c
478478
}
479479
if (this.isCellFocusType()) {
480480
this.setRowFocusType();
481-
this._focus(this._getCellElementFromTarget(eventArgs.originalEvent.target), true);
481+
this._focus(this.getCellElementFromTarget(eventArgs.originalEvent.target), true);
482482

483483
return true;
484484
}

0 commit comments

Comments
 (0)