mirror of https://github.com/portainer/portainer
fix(app): Make sure empty tables don't have select all rows checkbox checked (#489)
parent
b57855f20d
commit
28b222fffa
|
@ -155,6 +155,9 @@ describe('Datatable', () => {
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(screen.getByText('No data available')).toBeInTheDocument();
|
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', () => {
|
it('selects/deselects only page rows when select all is clicked', () => {
|
||||||
|
|
|
@ -3,7 +3,8 @@ import { ColumnDef, Row, Table } from '@tanstack/react-table';
|
||||||
import { Checkbox } from '@@/form-components/Checkbox';
|
import { Checkbox } from '@@/form-components/Checkbox';
|
||||||
|
|
||||||
function allRowsSelected<T>(table: Table<T>) {
|
function allRowsSelected<T>(table: Table<T>) {
|
||||||
return table.getCoreRowModel().rows.every((row) => row.getIsSelected());
|
const { rows } = table.getCoreRowModel();
|
||||||
|
return rows.length > 0 && rows.every((row) => row.getIsSelected());
|
||||||
}
|
}
|
||||||
|
|
||||||
function someRowsSelected<T>(table: Table<T>) {
|
function someRowsSelected<T>(table: Table<T>) {
|
||||||
|
|
Loading…
Reference in New Issue