mirror of
https://github.com/portainer/portainer.git
synced 2025-07-19 13:29:41 +02:00
fix(datatables): "Select all" should select only elements of the current page (#376)
This commit is contained in:
parent
379711951c
commit
5af0859f67
2 changed files with 54 additions and 3 deletions
|
@ -11,15 +11,22 @@ export function createSelectColumn<T>(dataCy: string): ColumnDef<T> {
|
|||
<Checkbox
|
||||
id="select-all"
|
||||
data-cy={`select-all-checkbox-${dataCy}`}
|
||||
checked={table.getIsAllRowsSelected()}
|
||||
checked={table.getIsAllPageRowsSelected()}
|
||||
indeterminate={table.getIsSomeRowsSelected()}
|
||||
onChange={table.getToggleAllRowsSelectedHandler()}
|
||||
onChange={(e) => {
|
||||
// Select all rows if shift key is held down, otherwise only page rows
|
||||
if (e.nativeEvent instanceof MouseEvent && e.nativeEvent.shiftKey) {
|
||||
table.getToggleAllRowsSelectedHandler()(e);
|
||||
return;
|
||||
}
|
||||
table.getToggleAllPageRowsSelectedHandler()(e);
|
||||
}}
|
||||
disabled={table.getRowModel().rows.every((row) => !row.getCanSelect())}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
}}
|
||||
aria-label="Select all rows"
|
||||
title="Select all rows"
|
||||
title="Select all rows. Hold shift key to select across all pages."
|
||||
/>
|
||||
),
|
||||
cell: ({ row, table }) => (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue