From d85c06948c65f84a9d7fb6784b99c0d0d78fb5be Mon Sep 17 00:00:00 2001 From: Kevin Van Cott Date: Fri, 17 Jul 2026 13:25:14 -0500 Subject: [PATCH] fix single-select parent row selection --- .../row-selection/rowSelectionFeature.utils.ts | 5 +++-- .../rowSelectionFeature.utils.test.ts | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/packages/table-core/src/features/row-selection/rowSelectionFeature.utils.ts b/packages/table-core/src/features/row-selection/rowSelectionFeature.utils.ts index 9e7d5960b5..09e90d6153 100644 --- a/packages/table-core/src/features/row-selection/rowSelectionFeature.utils.ts +++ b/packages/table-core/src/features/row-selection/rowSelectionFeature.utils.ts @@ -487,7 +487,8 @@ export function table_getToggleAllPageRowsSelectedHandler< * Selects or deselects this row. * * Omitting `value` toggles the row. Child rows are selected recursively unless - * `opts.selectChildren` is `false` or sub-row selection is disabled. + * `opts.selectChildren` is `false`, sub-row selection is disabled, or the row + * only supports single selection. * * @example * ```ts @@ -513,7 +514,7 @@ export function row_toggleSelected< rowSelection, row.id, value, - opts?.selectChildren ?? true, + (opts?.selectChildren ?? true) && row_getCanMultiSelect(row), row.table, ) diff --git a/packages/table-core/tests/unit/features/row-selection/rowSelectionFeature.utils.test.ts b/packages/table-core/tests/unit/features/row-selection/rowSelectionFeature.utils.test.ts index 061d7ae67c..6dde5d139a 100644 --- a/packages/table-core/tests/unit/features/row-selection/rowSelectionFeature.utils.test.ts +++ b/packages/table-core/tests/unit/features/row-selection/rowSelectionFeature.utils.test.ts @@ -353,6 +353,20 @@ describe('row_toggleSelected', () => { '0': true, }) }) + + it('should select the clicked parent row when multi-select is disabled', () => { + const onRowSelectionChange = vi.fn() + const table = makeTable( + { onRowSelectionChange, enableMultiRowSelection: false }, + [3, 2], + ) + + row_toggleSelected(table.getRow('0'), true) + + expect(getUpdaterResult(onRowSelectionChange, {})).toEqual({ + '0': true, + }) + }) }) describe('row_getIsSomeSelected / row_getIsAllSubRowsSelected', () => {