diff --git a/src/TreeDataGrid.tsx b/src/TreeDataGrid.tsx index 8f9a85d639..d88bad6b18 100644 --- a/src/TreeDataGrid.tsx +++ b/src/TreeDataGrid.tsx @@ -273,7 +273,7 @@ export function TreeDataGrid({ 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)); } @@ -282,7 +282,7 @@ export function TreeDataGrid({ } } 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)); } @@ -323,7 +323,7 @@ export function TreeDataGrid({ const parentRowAndIndex = getParentRowAndIndex(row); if (parentRowAndIndex !== undefined) { event.preventGridDefault(); - setActivePosition({ idx, rowIdx: parentRowAndIndex[1] }); + setActivePosition({ idx, rowIdx: parentRowAndIndex[1] }, { shouldFocus: true }); } } } diff --git a/test/browser/TreeDataGrid.test.tsx b/test/browser/TreeDataGrid.test.tsx index 8c825013a9..e8be78a270 100644 --- a/test/browser/TreeDataGrid.test.tsx +++ b/test/browser/TreeDataGrid.test.tsx @@ -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);