diff --git a/public/app/features/browse-dashboards/components/CheckboxHeaderCell.tsx b/public/app/features/browse-dashboards/components/CheckboxHeaderCell.tsx index 910a18103b3..b476b803f3d 100644 --- a/public/app/features/browse-dashboards/components/CheckboxHeaderCell.tsx +++ b/public/app/features/browse-dashboards/components/CheckboxHeaderCell.tsx @@ -11,7 +11,14 @@ export default function CheckboxHeaderCell({ isSelected, onAllSelectionChange }: onAllSelectionChange?.(ev.currentTarget.checked)} + onChange={(ev) => { + if (state === SelectionState.Mixed) { + // Ensure clicking an indeterminate checkbox always clears the selection + onAllSelectionChange?.(false); + } else { + onAllSelectionChange?.(ev.currentTarget.checked); + } + }} /> ); } diff --git a/public/app/features/search/page/components/columns.tsx b/public/app/features/search/page/components/columns.tsx index 5369dadc035..f30bbc15eb9 100644 --- a/public/app/features/search/page/components/columns.tsx +++ b/public/app/features/search/page/components/columns.tsx @@ -64,21 +64,21 @@ export const generateColumns = ( id: `column-checkbox`, width, Header: () => { + const { view } = response; + const hasSelection = selection('*', '*'); + const allSelected = view.every((item) => selection(item.kind, item.uid)); return ( { - const { view } = response; - const count = Math.min(view.length, 50); - const hasSelection = selection('*', '*'); - for (let i = 0; i < count; i++) { - const item = view.get(i); - if (item.uid && item.kind) { - if (hasSelection === selection(item.kind, item.uid)) { - selectionToggle(item.kind, item.uid); - } + if (hasSelection) { + clearSelection(); + } else { + for (let i = 0; i < view.length; i++) { + const item = view.get(i); + selectionToggle(item.kind, item.uid); } } }}