Skip to content

Commit

Permalink
Ensure isSubRowSelected returns false if no subRows are sele:ctable
Browse files Browse the repository at this point in the history
  • Loading branch information
Joel 'Aaron' Cohen committed Nov 4, 2024
1 parent 82ee099 commit e762532
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/table-core/src/features/RowSelection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,7 @@ export function isSubRowSelected<TData extends RowData>(

let allChildrenSelected = true
let someSelected = false
let someSelectable = false

row.subRows.forEach(subRow => {
// Bail out early if we know both of these
Expand All @@ -643,6 +644,7 @@ export function isSubRowSelected<TData extends RowData>(
}

if (subRow.getCanSelect()) {
someSelectable = true
if (isRowSelected(subRow, selection)) {
someSelected = true
} else {
Expand All @@ -664,5 +666,7 @@ export function isSubRowSelected<TData extends RowData>(
}
})

if (!someSelectable) return false

return allChildrenSelected ? 'all' : someSelected ? 'some' : false
}

0 comments on commit e762532

Please sign in to comment.