From 6af6819758ecac758273fe3509ed740e326fff80 Mon Sep 17 00:00:00 2001 From: Joel 'Aaron' Cohen Date: Mon, 4 Nov 2024 16:55:10 -0500 Subject: [PATCH] Ensure isSubRowSelected returns false if no subRows are selctable --- packages/table-core/src/features/RowSelection.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/table-core/src/features/RowSelection.ts b/packages/table-core/src/features/RowSelection.ts index 90166823aa..aebbe6d2bf 100644 --- a/packages/table-core/src/features/RowSelection.ts +++ b/packages/table-core/src/features/RowSelection.ts @@ -445,8 +445,8 @@ export const RowSelection: TableFeature = { return table.getIsAllPageRowsSelected() ? false : paginationFlatRows - .filter(row => row.getCanSelect()) - .some(d => d.getIsSelected() || d.getIsSomeSelected()) + .filter(row => row.getCanSelect()) + .some(d => d.getIsSelected() || d.getIsSomeSelected()) } table.getToggleAllRowsSelectedHandler = () => { @@ -635,6 +635,7 @@ export function isSubRowSelected( let allChildrenSelected = true let someSelected = false + let someSelectable = false row.subRows.forEach(subRow => { // Bail out early if we know both of these @@ -643,6 +644,7 @@ export function isSubRowSelected( } if (subRow.getCanSelect()) { + someSelectable = true if (isRowSelected(subRow, selection)) { someSelected = true } else { @@ -664,5 +666,7 @@ export function isSubRowSelected( } }) + if (!someSelectable) return false + return allChildrenSelected ? 'all' : someSelected ? 'some' : false }