1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-28 01:39:39 +02:00

fix(datatables): "Select all" should select only elements of the current page (#377)

This commit is contained in:
James Player 2025-02-04 15:51:11 +13:00 committed by GitHub
parent a43bb23bef
commit b73f846397
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 }) => (