Skip to content

Commit

Permalink
DataGrid - Master-detail - It's not possible to focus all rows after …
Browse files Browse the repository at this point in the history
…rows are expanded and collapsed (T1187124) (#25543)
  • Loading branch information
pomahtri authored Sep 11, 2023
1 parent 7f267db commit 9ac8579
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1733,17 +1733,19 @@ export class KeyboardNavigationController extends modules.ViewController {
return this._isCellValid($cell);
}

_isLastRow(rowIndex) {
const dataController = this._dataController as any;
const visibleItems = dataController
.items()
.filter((item) => item.visible !== false);
private _isLastRow(rowIndex: number): boolean {
const dataController = this._dataController;

if (this._isVirtualRowRender()) {
return rowIndex >= dataController.getMaxRowIndex();
return rowIndex >= (dataController as any).getMaxRowIndex();
}

return rowIndex === visibleItems.length - 1;
const lastVisibleIndex = Math.max(
...dataController.items()
.map((item, index) => (item.visible !== false ? index : -1)),
);

return rowIndex === lastVisibleIndex;
}

_isFirstValidCell(cellPosition) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4334,7 +4334,7 @@ test('Focus first cell with dropDownButton (via tab key) -> open dropDownButton
});
},
}, 'field2', 'field3'],
}, undefined, { disableFxAnimation: true }));
}));

// T1185341
test('Focus second cell (via click) -> tab navigation when focusedRowEnabled is true', async (t) => {
Expand Down Expand Up @@ -4373,4 +4373,41 @@ test('Focus second cell (via click) -> tab navigation when focusedRowEnabled is
});
},
}, 'field2', 'field3'],
}, undefined, { disableFxAnimation: true }));
}));

// T1187124
test('Keyboard navigation should work after opening-closing master-detal', async (t) => {
const dataGrid = new DataGrid('#container');

await t.click(dataGrid.getDataRow(0).getCommandCell(0).element); // open master detail
await t.click(dataGrid.getDataRow(0).getCommandCell(0).element); // close master detail

await t
.click(dataGrid.getHeaders().getHeaderRow(0).getHeaderCell(1).element)
.pressKey('tab')
.pressKey('tab')
.expect(dataGrid.getDataCell(0, 1).isFocused)
.ok();

await t
.pressKey('down')
.expect(dataGrid.getDataCell(1, 1).isFocused).ok();

await t
.pressKey('down')
.expect(dataGrid.getDataCell(2, 1).isFocused).ok();
await t
.pressKey('down')
.expect(dataGrid.getDataCell(3, 1).isFocused).ok();
}).before(async () => createWidget('dxDataGrid', {
dataSource: [
{ id: 1 },
{ id: 2 },
{ id: 3 },
{ id: 4 },
],
keyExpr: 'id',
masterDetail: {
enabled: true,
},
}));

0 comments on commit 9ac8579

Please sign in to comment.