Skip to content

Commit ff0bbbb

Browse files
authored
fix: getIsAllPageRowsSelected when row selection is enabled conditionally (#4690)
* fix getIsAllPageRowsSelected when enableRowSelection is conditional
1 parent 160b983 commit ff0bbbb

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

examples/react/row-selection/src/main.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ function App() {
4040
<IndeterminateCheckbox
4141
{...{
4242
checked: row.getIsSelected(),
43+
disabled: !row.getCanSelect(),
4344
indeterminate: row.getIsSomeSelected(),
4445
onChange: row.getToggleSelectedHandler(),
4546
}}
@@ -109,6 +110,8 @@ function App() {
109110
state: {
110111
rowSelection,
111112
},
113+
enableRowSelection: true, //enable row selection for all rows
114+
// enableRowSelection: row => row.original.age > 18, // or enable row selection conditionally per row
112115
onRowSelectionChange: setRowSelection,
113116
getCoreRowModel: getCoreRowModel(),
114117
getFilteredRowModel: getFilteredRowModel(),

packages/table-core/src/features/RowSelection.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,9 @@ export const RowSelection: TableFeature = {
295295

296296
if (
297297
isAllPageRowsSelected &&
298-
paginationFlatRows.some(row => !rowSelection[row.id])
298+
paginationFlatRows.some(
299+
row => row.getCanSelect() && !rowSelection[row.id]
300+
)
299301
) {
300302
isAllPageRowsSelected = false
301303
}

0 commit comments

Comments
 (0)