Skip to content

Commit 0475eec

Browse files
AniYeahclaude
andcommitted
Uniquely label Reason/Follow-up toggles for screen readers
Every question row in Institution / Privacy analyst views has its own "+ Reason / Follow-up" button, and until now they all shared identical accessible names — a WCAG-failing "ambiguous link/button purpose" for screen-reader users trying to orient among dozens of identical toggles. Fix by giving each question row's .qmeta div an id (e.g. "aqmeta-inst-eval-AAAI-01") and wrapping the button's own text in a span with its own id, then setting aria-labelledby on the button to reference both. The browser concatenates the two, so AT now announces something like "Plus Reason / Follow-up, AAAI-01 Critical, button, collapsed" — unambiguous per question. The click handler still updates the span's textContent to toggle the + / − prefix; aria-labelledby picks up the new string on the next read. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 8346395 commit 0475eec

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

hecvat-app.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2145,7 +2145,13 @@ var HECVAT_SEC = (function () {
21452145

21462146
/* Left column */
21472147
var L = mk('div');
2148-
var meta = mk('div', 'qmeta'); meta.appendChild(txt(q.id));
2148+
/* qmeta is given an ID so the Reason / Follow-up toggle below can
2149+
reference it via aria-labelledby — that makes the toggle's
2150+
accessible name include the question ID (e.g. "AAAI-01"),
2151+
so screen-reader users can tell the otherwise-identical
2152+
"+ Reason / Follow-up" buttons apart. */
2153+
var metaId = 'aqmeta-' + evalId + '-' + q.id;
2154+
var meta = mk('div', 'qmeta'); meta.id = metaId; meta.appendChild(txt(q.id));
21492155
if (crit) { var bc = mk('span','bdg bdg-c'); bc.textContent='\u2605 Critical'; meta.appendChild(bc); }
21502156
L.appendChild(meta);
21512157
var qt = mk('div','qtext'); qt.id='aqt-'+evalId+'-'+q.id; qt.appendChild(txt(q.q)); L.appendChild(qt);
@@ -2163,7 +2169,18 @@ var HECVAT_SEC = (function () {
21632169
attr(rtog,'aria-expanded','false');
21642170
attr(rtog,'aria-controls','reason-'+evalId+'-'+q.id);
21652171
attr(rtog,'data-reason-for', evalId+'-'+q.id);
2166-
rtog.appendChild(txt('+ Reason / Follow-up')); L.appendChild(rtog);
2172+
/* Accessible name = [the button's own "+ Reason / Follow-up" span]
2173+
+ [the qmeta div with the question ID and critical badge]. The
2174+
browser concatenates the referenced text, so a screen reader
2175+
announces e.g. "Plus Reason / Follow-up, AAAI-01 Critical,
2176+
button, collapsed". That ID disambiguates every toggle on the
2177+
page. */
2178+
var rtogLblId = 'rtog-lbl-' + evalId + '-' + q.id;
2179+
attr(rtog, 'aria-labelledby', rtogLblId + ' ' + metaId);
2180+
var rtogLbl = mk('span'); rtogLbl.id = rtogLblId;
2181+
rtogLbl.appendChild(txt('+ Reason / Follow-up'));
2182+
rtog.appendChild(rtogLbl);
2183+
L.appendChild(rtog);
21672184
var rarea = mk('div','reason-area'); rarea.id='reason-'+evalId+'-'+q.id;
21682185
if (q.reason) { var rh=mk('strong'); rh.appendChild(txt('Reason for Question')); rarea.appendChild(rh); rarea.appendChild(txt(q.reason)); }
21692186
if (q.followup){ var fh=mk('strong'); fh.appendChild(txt('Follow-up Guidance')); rarea.appendChild(fh); rarea.appendChild(txt(q.followup)); }

0 commit comments

Comments
 (0)