From 5a3beaae9651f5dbf8281fce2a7e97676868e2de Mon Sep 17 00:00:00 2001 From: Ivo Oskamp Date: Thu, 1 Jan 2026 17:42:47 +0100 Subject: [PATCH] Auto-commit local changes before build (2026-01-01 17:42:47) --- .last-branch | 2 +- .../src/templates/main/run_checks.html | 77 ++++++++++--------- docs/changelog.md | 8 ++ 3 files changed, 50 insertions(+), 37 deletions(-) diff --git a/.last-branch b/.last-branch index 25ccaa6..e0b81af 100644 --- a/.last-branch +++ b/.last-branch @@ -1 +1 @@ -v20260101-11-run-checks-select-all-indeterminate-clear-selection +v20260101-12-run-checks-select-all-indeterminate-clear-selection-fix diff --git a/containers/backupchecks/src/templates/main/run_checks.html b/containers/backupchecks/src/templates/main/run_checks.html index 13ab750..b014c3d 100644 --- a/containers/backupchecks/src/templates/main/run_checks.html +++ b/containers/backupchecks/src/templates/main/run_checks.html @@ -279,38 +279,6 @@ var btnMark = document.getElementById('btn_mark_reviewed'); var btnUnmark = document.getElementById('btn_unmark_reviewed'); var statusEl = document.getElementById('rc_status'); - // Header checkbox behavior: - // - When indeterminate (partial selection), clicking/pressing Space clears all selections. - // - Otherwise behaves as a normal "select all / select none". - function clearAllSelections() { - var cbs = table.querySelectorAll('tbody .rc_row_cb'); - cbs.forEach(function (cb) { cb.checked = false; }); - if (selectAll) { - selectAll.indeterminate = false; - selectAll.checked = false; - } - updateButtons(); - } - - if (selectAll) { - selectAll.addEventListener('click', function (e) { - if (selectAll.indeterminate) { - e.preventDefault(); - e.stopPropagation(); - clearAllSelections(); - } - }); - - selectAll.addEventListener('keydown', function (e) { - // Space toggles checkbox via keyboard - if ((e.key === ' ' || e.key === 'Spacebar' || e.code === 'Space') && selectAll.indeterminate) { - e.preventDefault(); - e.stopPropagation(); - clearAllSelections(); - } - }); - } - var currentJobId = null; var currentRunId = null; @@ -413,13 +381,50 @@ function statusClass(status) { } if (selectAll) { + function clearAllSelection() { + var cbs = table.querySelectorAll('tbody .rc_row_cb'); + cbs.forEach(function (cb) { cb.checked = false; }); + // Ensure header checkbox is reset as well. + selectAll.indeterminate = false; + selectAll.checked = false; + updateButtons(); + } + + // When the header checkbox is indeterminate (partial selection), users expect a click + // to clear the selection, not to select everything. + var selectAllWasIndeterminate = false; + + selectAll.addEventListener('mousedown', function () { + selectAllWasIndeterminate = !!selectAll.indeterminate; + }, true); + + selectAll.addEventListener('click', function (e) { + if (selectAllWasIndeterminate) { + e.preventDefault(); + e.stopPropagation(); + clearAllSelection(); + selectAllWasIndeterminate = false; + } + }, true); + + selectAll.addEventListener('keydown', function (e) { + // Space toggles checkboxes. If indeterminate, treat Space as "clear selection". + if ((e.key === ' ' || e.code === 'Space') && selectAll.indeterminate) { + e.preventDefault(); + e.stopPropagation(); + clearAllSelection(); + } + }, true); + selectAll.addEventListener('change', function () { - // Safety net: in case the checkbox becomes checked while it was indeterminate, - // treat it as "clear all" (expected UX). - if (selectAll.indeterminate && selectAll.checked) { - clearAllSelections(); + // Safety net: if any browser still fires change after an indeterminate click, + // force the expected "clear" behavior. + if (selectAllWasIndeterminate) { + clearAllSelection(); + selectAllWasIndeterminate = false; return; } + var cbs = table.querySelectorAll('tbody .rc_row_cb'); cbs.forEach(function (cb) { cb.checked = selectAll.checked; }); updateButtons(); diff --git a/docs/changelog.md b/docs/changelog.md index 104dd06..20579d4 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -184,6 +184,14 @@ - Prevented unintended full selection when toggling from an indeterminate state. - Ensured consistent behavior between mouse click and keyboard (Space) interaction on the header checkbox. +--- + +## v20260101-12-run-checks-select-all-indeterminate-clear-selection-fix + +- Fixed the Run Checks header “select all” checkbox: when it is indeterminate (partial selection), clicking it now clears the current selection instead of selecting all rows. +- Implemented click interception before the browser toggles the checkbox state to prevent unintended full selection from the indeterminate state. +- Added consistent keyboard behavior: pressing Space on the indeterminate header checkbox now also clears the selection. + ================================================================================================================================================ ## v0.1.14