Skip to content
Open
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
6 changes: 3 additions & 3 deletions src/TreeDataGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ export function TreeDataGrid<R, SR = unknown, K extends Key = Key>({
const key = rowKeyGetter(row);
if (selectedRows?.has(key) && !newSelectedRows.has(key)) {
if (isGroupRow(row)) {
// select all children if the parent row is selected
// unselect all children if the parent row is unselected
for (const cr of row.childRows) {
newRawSelectedRows.delete(rawRowKeyGetter(cr));
}
Expand All @@ -282,7 +282,7 @@ export function TreeDataGrid<R, SR = unknown, K extends Key = Key>({
}
} else if (!selectedRows?.has(key) && newSelectedRows.has(key)) {
if (isGroupRow(row)) {
// unselect all children if the parent row is unselected
// select all children if the parent row is selected
for (const cr of row.childRows) {
newRawSelectedRows.add(rawRowKeyGetter(cr));
}
Expand Down Expand Up @@ -323,7 +323,7 @@ export function TreeDataGrid<R, SR = unknown, K extends Key = Key>({
const parentRowAndIndex = getParentRowAndIndex(row);
if (parentRowAndIndex !== undefined) {
event.preventGridDefault();
setActivePosition({ idx, rowIdx: parentRowAndIndex[1] });
setActivePosition({ idx, rowIdx: parentRowAndIndex[1] }, { shouldFocus: true });
}
}
}
Expand Down
1 change: 1 addition & 0 deletions test/browser/TreeDataGrid.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ test('cell navigation in a treegrid', async () => {
await expect.element(rows.nth(1)).not.toHaveClass(rowActiveClassname);
await userEvent.keyboard('{arrowleft}{arrowleft}');
await expect.element(rows.nth(1)).toHaveClass(rowActiveClassname);
await expect.element(rows.nth(1)).toHaveFocus();

await userEvent.keyboard('{end}');
await expect.element(rows.nth(5)).toHaveClass(rowActiveClassname);
Expand Down
Loading