diff --git a/app/react/components/datatables/Datatable.test.tsx b/app/react/components/datatables/Datatable.test.tsx index 5664a3ed6..67ff85f70 100644 --- a/app/react/components/datatables/Datatable.test.tsx +++ b/app/react/components/datatables/Datatable.test.tsx @@ -155,6 +155,9 @@ describe('Datatable', () => { ); expect(screen.getByText('No data available')).toBeInTheDocument(); + const selectAllCheckbox: HTMLInputElement = + screen.getByLabelText('Select all rows'); + expect(selectAllCheckbox.checked).toBe(false); }); it('selects/deselects only page rows when select all is clicked', () => { diff --git a/app/react/components/datatables/select-column.tsx b/app/react/components/datatables/select-column.tsx index 46329588a..2e4a04272 100644 --- a/app/react/components/datatables/select-column.tsx +++ b/app/react/components/datatables/select-column.tsx @@ -3,7 +3,8 @@ import { ColumnDef, Row, Table } from '@tanstack/react-table'; import { Checkbox } from '@@/form-components/Checkbox'; function allRowsSelected(table: Table) { - return table.getCoreRowModel().rows.every((row) => row.getIsSelected()); + const { rows } = table.getCoreRowModel(); + return rows.length > 0 && rows.every((row) => row.getIsSelected()); } function someRowsSelected(table: Table) {