fix: screen-reader fixes for day highlights button and chips toggle
The Highlights button's aria-label overrode its content, so the visible "· analysed" suffix was never announced — the analysed state is now mirrored into the label (at render and when a highlights run completes). The chips toggle's accessible text started with a stray space (left over once the aria-hidden arrow is dropped), which read as an indent; the separator space now lives inside the aria-hidden arrow span. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
+13
-6
@@ -765,7 +765,7 @@ function renderFiles(files) {
|
||||
</h2>
|
||||
${canHl ? `<button class="day-hl" id="dayhln-${dayId}"
|
||||
aria-expanded="false" aria-controls="dayhl-${dayId}"
|
||||
aria-label="Day highlights for ${esc(day)}">
|
||||
aria-label="Day highlights for ${esc(day)}${analysed ? ', analysed' : ''}">
|
||||
<span class="day-arrow" aria-hidden="true">▸</span> Highlights<span
|
||||
class="day-hl-status" id="dayhls-${dayId}"${analysed ? '' : ' hidden'}> · analysed</span></button>` : ''}`;
|
||||
section.appendChild(headBar);
|
||||
@@ -1046,16 +1046,18 @@ async function dayHighlights(dayId, analyzableFiles) {
|
||||
const arrow = document.createElement('span');
|
||||
arrow.className = 'day-arrow';
|
||||
arrow.setAttribute('aria-hidden', 'true');
|
||||
arrow.textContent = '▸';
|
||||
// the separator space lives inside the aria-hidden arrow: a leading
|
||||
// space in the text node shows up as an indent in screen readers
|
||||
arrow.textContent = '▸ ';
|
||||
tog.appendChild(arrow);
|
||||
tog.appendChild(document.createTextNode(truncated
|
||||
? ` Top ${chipList.length} sections by loudness`
|
||||
: ` ${chipList.length} sections`));
|
||||
? `Top ${chipList.length} sections by loudness`
|
||||
: `${chipList.length} sections`));
|
||||
tog.addEventListener('click', () => {
|
||||
const exp = chips.hidden;
|
||||
chips.hidden = !exp;
|
||||
tog.setAttribute('aria-expanded', exp);
|
||||
arrow.textContent = exp ? '▾' : '▸';
|
||||
arrow.textContent = exp ? '▾ ' : '▸ ';
|
||||
});
|
||||
box.appendChild(tog);
|
||||
}
|
||||
@@ -1067,8 +1069,13 @@ async function dayHighlights(dayId, analyzableFiles) {
|
||||
hlRow.dataset.loaded = hlParams();
|
||||
dayHlSections.set(dayId, dayActiveSections);
|
||||
// Every file is now cached with the current params
|
||||
if (results.length === n)
|
||||
if (results.length === n) {
|
||||
document.getElementById('dayhls-' + dayId)?.removeAttribute('hidden');
|
||||
// aria-label overrides the button content, so the analysed marker has to
|
||||
// be mirrored into it or screen readers never hear it
|
||||
if (btn && !/, analysed$/.test(btn.getAttribute('aria-label') || ''))
|
||||
btn.setAttribute('aria-label', btn.getAttribute('aria-label') + ', analysed');
|
||||
}
|
||||
if (btn) btn.disabled = false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user