Skip to content

Commit

Permalink
fix clear selection button to clear all pages
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinVandy committed Feb 9, 2024
1 parent 613245a commit 35fe3cf
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export const MRT_SelectCheckbox = <TData extends MRT_RowData>({
},
onChange: (event) => {
event.stopPropagation();
row ? onSelectionChange!(event) : onSelectAllChange(event);
selectAll ? onSelectAllChange(event) : onSelectionChange!(event);
},
size: (density === 'compact' ? 'small' : 'medium') as 'medium' | 'small',
...checkboxProps,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ export const MRT_ToolbarAlertBanner = <TData extends MRT_RowData>({
?.replace('{selectedCount}', selectedRowCount.toLocaleString())
?.replace('{rowCount}', totalRowCount.toString())}
<Button
onClick={(event) => getMRT_SelectAllHandler({ table })(event, false)}
onClick={(event) =>
getMRT_SelectAllHandler({ table })(event, false, true)
}
size="small"
sx={{ p: '2px' }}
>
Expand Down
3 changes: 2 additions & 1 deletion packages/material-react-table/src/utils/row.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,14 @@ export const getMRT_SelectAllHandler =
(
event: ChangeEvent<HTMLInputElement> | MouseEvent<HTMLButtonElement>,
value?: boolean,
forceAll?: boolean,
) => {
const {
options: { enableRowPinning, rowPinningDisplayMode, selectAllMode },
refs: { lastSelectedRowId },
} = table;

selectAllMode === 'all'
selectAllMode === 'all' || forceAll
? table.toggleAllRowsSelected(value ?? (event as any).target.checked)
: table.toggleAllPageRowsSelected(value ?? (event as any).target.checked);
if (enableRowPinning && rowPinningDisplayMode?.includes('select')) {
Expand Down

0 comments on commit 35fe3cf

Please sign in to comment.