1
0
Fork 0
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:
James Player 2025-02-04 15:34:33 +13:00 committed by GitHub
parent 379711951c
commit 5af0859f67
2 changed files with 54 additions and 3 deletions

View file

@ -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 }) => (