Compare commits

...

2 Commits

3 changed files with 49 additions and 40 deletions

View File

@ -1 +1 @@
v20260101-12-run-checks-select-all-indeterminate-clear-selection-fix v20260101-13-run-checks-select-all-indeterminate-state-fix

View File

@ -381,57 +381,57 @@ function statusClass(status) {
} }
if (selectAll) { if (selectAll) {
function clearAllSelection() { function setAllSelection(checked) {
var cbs = table.querySelectorAll('tbody .rc_row_cb'); var cbs = table.querySelectorAll('tbody .rc_row_cb');
cbs.forEach(function (cb) { cb.checked = false; }); cbs.forEach(function (cb) { cb.checked = !!checked; });
// Ensure header checkbox is reset as well.
// Keep header checkbox state in sync and avoid a "stuck" indeterminate UI.
selectAll.indeterminate = false; selectAll.indeterminate = false;
selectAll.checked = false; selectAll.checked = !!checked;
updateButtons(); updateButtons();
} }
// When the header checkbox is indeterminate (partial selection), users expect a click function toggleHeaderSelection(e) {
// to clear the selection, not to select everything. if (e) {
var selectAllWasIndeterminate = false;
selectAll.addEventListener('mousedown', function () {
selectAllWasIndeterminate = !!selectAll.indeterminate;
}, true);
selectAll.addEventListener('click', function (e) {
if (selectAllWasIndeterminate) {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); 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: 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'); var cbs = table.querySelectorAll('tbody .rc_row_cb');
cbs.forEach(function (cb) { cb.checked = selectAll.checked; }); var total = cbs.length;
updateButtons(); if (!total) {
}); // No rows; always reset header state.
selectAll.indeterminate = false;
selectAll.checked = false;
updateButtons();
return;
}
var checked = 0;
cbs.forEach(function (cb) { if (cb.checked) checked++; });
// Behavior:
// - none selected => select all
// - all selected => clear all
// - partial selection (indeterminate) => clear selection
var target = (checked === 0);
setAllSelection(target);
}
// Fully control header checkbox behavior to prevent indeterminate state from getting stuck.
selectAll.addEventListener('click', toggleHeaderSelection, true);
selectAll.addEventListener('keydown', function (e) {
// Space/Enter should behave the same as a click.
if (e.key === ' ' || e.code === 'Space' || e.key === 'Enter') {
toggleHeaderSelection(e);
}
}, true);
} }
// Prevent browser text selection when using Shift with checkbox selection // Prevent browser text selection when using Shift with checkbox selection
table.addEventListener('mousedown', function (e) { table.addEventListener('mousedown', function (e) {
var t = e.target; var t = e.target;
if (!t) return; if (!t) return;

View File

@ -192,6 +192,15 @@
- Implemented click interception before the browser toggles the checkbox state to prevent unintended full selection from the indeterminate state. - 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. - Added consistent keyboard behavior: pressing Space on the indeterminate header checkbox now also clears the selection.
---
## v20260101-13-run-checks-select-all-indeterminate-state-fix
- Fixed the “Select all” checkbox behavior on the Run Checks page.
- Resolved an issue where the checkbox remained in the indeterminate (`-`) state after clearing the selection.
- Ensured that after clearing all selected rows, the “Select all” checkbox can again be used to select all rows normally.
- Improved synchronization between individual row selection and the global “Select all” checkbox state.
================================================================================================================================================ ================================================================================================================================================
## v0.1.14 ## v0.1.14