Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataGrid - Master-detail - It's not possible to focus all rows after rows are expanded and collapsed (T1187124) #25568

Merged
merged 1 commit into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1721,17 +1721,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 @@ -4244,7 +4244,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 @@ -4283,4 +4283,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,
},
}));