fix(adjustments): rename Select-All header checkbox id to avoid collision

Code-review follow-up on Task 6:

Task 4 gave the Adjustments table's 'select all' header checkbox the
id 'adjSelectAll' — but the Add-Adjustment modal already had an
<a id='adjSelectAll'> Select-All anchor (and a matching JS click
handler on line 1823). Duplicate IDs are invalid HTML, and
getElementById returns the first occurrence in DOM order — so the
modal's Select-All handler silently started binding to the table
checkbox instead of its intended anchor. Never reported because
neither element was automated-tested.

Rename the table checkbox id to #adjTableSelectAll and update Task 6's
bulk-select JS to match. The modal's handler now correctly binds to
its own anchor again.

62/62 tests still pass — behaviour is template-driven UI, no backend
change.
This commit is contained in:
Konrad du Plessis 2026-04-23 18:57:43 +02:00
parent 03f177e7d0
commit 5f2e6d8c74

View File

@ -777,7 +777,10 @@
<th style="width: 40px;">
{# aria-label is the accessible name screen readers announce; #}
{# title= is kept as the mouse-hover tooltip for sighted users. #}
<input type="checkbox" class="form-check-input" id="adjSelectAll"
{# Distinct id from the Add-Adjustment modal's own #adjSelectAll #}
{# anchor (line ~940) — duplicate ids are invalid HTML and caused the #}
{# modal's Select-All handler to silently bind to this checkbox instead. #}
<input type="checkbox" class="form-check-input" id="adjTableSelectAll"
aria-label="Select all unpaid adjustments on this page"
title="Select all unpaid on this page">
</th>
@ -3596,14 +3599,16 @@ document.addEventListener('DOMContentLoaded', function() {
// === ADJUSTMENTS TAB — bulk select + delete ===
// The per-row checkboxes come from _adjustment_row.html (class
// .adj-bulk-checkbox on unpaid rows only; disabled dummy checkbox on
// paid rows for visual alignment). The header has an #adjSelectAll
// that toggles all visible unpaid checkboxes. A floating action bar
// (#adjBulkBar) appears when >=1 row is selected.
// paid rows for visual alignment). The header has #adjTableSelectAll
// (renamed from #adjSelectAll to avoid a duplicate-id collision with
// the Add-Adjustment modal's own Select-All anchor) that toggles all
// visible unpaid checkboxes. A floating action bar (#adjBulkBar)
// appears when >=1 row is selected.
var bulkBar = document.getElementById('adjBulkBar');
var bulkCount = document.getElementById('adjBulkCount');
var bulkDeleteBtn = document.getElementById('adjBulkDeleteBtn');
var bulkClearBtn = document.getElementById('adjBulkClearBtn');
var selectAll = document.getElementById('adjSelectAll');
var selectAll = document.getElementById('adjTableSelectAll');
// CSRF via cookie — Django middleware sets this cookie on GET requests.
function getCookie(name) {