Skip to content
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 @@ -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
Expand All @@ -513,7 +514,7 @@ export function row_toggleSelected<
rowSelection,
row.id,
value,
opts?.selectChildren ?? true,
(opts?.selectChildren ?? true) && row_getCanMultiSelect(row),
row.table,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
Loading