diff --git a/.last-branch b/.last-branch index 11b078b..eaadeb1 100644 --- a/.last-branch +++ b/.last-branch @@ -1 +1 @@ -v20260101-09-run-checks-shift-multiselect-range-highlight-fix +v20260101-10-run-checks-shift-multiselect-last-row-checkbox-fix diff --git a/containers/backupchecks/src/templates/main/run_checks.html b/containers/backupchecks/src/templates/main/run_checks.html index c908039..0e28868 100644 --- a/containers/backupchecks/src/templates/main/run_checks.html +++ b/containers/backupchecks/src/templates/main/run_checks.html @@ -425,6 +425,9 @@ table.addEventListener('click', function (e) { // Use the remembered pre-click state to avoid double toggling in some browsers var preChecked = (lastMouseDownCb === t ? lastMouseDownChecked : t.checked); var targetChecked = !preChecked; + // Some browsers may still reconcile the default checkbox toggle after this handler. + // Apply the intended state now and once more on the next tick to ensure the clicked + // checkbox remains in-sync with the highlighted range. t.checked = targetChecked; // Reset mousedown tracking once we've consumed it @@ -438,20 +441,38 @@ table.addEventListener('click', function (e) { var start = startRow ? rows.indexOf(startRow) : -1; var end = endRow ? rows.indexOf(endRow) : -1; + var lo = -1; + var hi = -1; if (start !== -1 && end !== -1) { - var lo = Math.min(start, end); - var hi = Math.max(start, end); - for (var i = lo; i <= hi; i++) { - var cb = rows[i].querySelector('.rc_row_cb'); - if (cb) cb.checked = targetChecked; + lo = Math.min(start, end); + hi = Math.max(start, end); + } + + function applyRangeCheckedState() { + // Always re-assert the clicked checkbox state. + t.checked = targetChecked; + + if (lo !== -1 && hi !== -1) { + for (var i = lo; i <= hi; i++) { + var cb = rows[i].querySelector('.rc_row_cb'); + if (cb) cb.checked = targetChecked; + } } } + applyRangeCheckedState(); + if (window.getSelection) { try { window.getSelection().removeAllRanges(); } catch (err) {} } - updateButtons(); + // Ensure the final visual state matches the final checkbox state. + // If the browser applies a late default toggle reconciliation, this second + // pass keeps both the checkmarks and row highlights correct. + setTimeout(function () { + applyRangeCheckedState(); + updateButtons(); + }, 0); lastCheckedCb = t; return; } diff --git a/docs/changelog.md b/docs/changelog.md index 217e263..d9b4751 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -167,6 +167,15 @@ - Corrected an off-by-one issue where selection previously stopped one row above the clicked item. - Added visual highlighting for all rows that are selected via checkmarks to clearly indicate active selection. +--- + +## v20260101-10-run-checks-shift-multiselect-last-row-checkbox-fix + +### Fixed +- Fixed an issue on the Run Checks page where the last row in a shift-selected range was visually highlighted but its checkbox was not checked. +- Ensured checkbox state and row highlight state stay fully in sync for all rows in a shift multi-selection. +- Corrected selection logic so every row within the calculated range is consistently selected and marked. + ================================================================================================================================================ ## v0.1.14