Skip to content

Commit

Permalink
getIsSomeRowsSelected should not return false when all rows are selected
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinVandy committed Jun 30, 2024
1 parent e42f9dd commit a0f1cc3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
2 changes: 1 addition & 1 deletion examples/react/row-selection/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { HTMLAttributes, HTMLProps } from 'react'
import React, { HTMLProps } from 'react'
import ReactDOM from 'react-dom/client'

import './index.css'
Expand Down
17 changes: 4 additions & 13 deletions packages/table-core/src/features/RowSelection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -431,22 +431,13 @@ export const RowSelection: TableFeature = {
}

table.getIsSomeRowsSelected = () => {
const totalSelected = Object.keys(
table.getState().rowSelection ?? {}
).length
return (
totalSelected > 0 &&
totalSelected <= table.getFilteredRowModel().flatRows.length
)
return Object.keys(table.getState().rowSelection ?? {}).length > 0
}

table.getIsSomePageRowsSelected = () => {
const paginationFlatRows = table.getPaginationRowModel().flatRows
return table.getIsAllPageRowsSelected()
? false
: paginationFlatRows
.filter(row => row.getCanSelect())
.some(d => d.getIsSelected() || d.getIsSomeSelected())
return table
.getPaginationRowModel()
.flatRows.some(r => r.getIsSelected() || r.getIsSomeSelected())
}

table.getToggleAllRowsSelectedHandler = () => {
Expand Down

0 comments on commit a0f1cc3

Please sign in to comment.