Skip to content

Commit 6317a2e

Browse files
Copilotmarcoacierno
andcommitted
Fix accessibility, consolidate event listeners, and use page-specific localStorage keys
Co-authored-by: marcoacierno <[email protected]>
1 parent d8ead9b commit 6317a2e

File tree

2 files changed

+47
-37
lines changed

2 files changed

+47
-37
lines changed

backend/reviews/templates/grants-recap.html

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -572,39 +572,45 @@
572572
});
573573
};
574574

575-
window.addEventListener('load', initSorting);
575+
window.addEventListener('load', () => {
576+
initSorting();
577+
578+
// Initialize bottom bar toggle functionality
579+
const bottomBarHidden = localStorage.getItem('grantsBottomBarHidden') === 'true';
580+
const bottomBar = document.querySelector('.reviews-bottom-bar');
581+
const toggleIcon = document.getElementById('toggle-icon');
582+
const toggleButton = document.getElementById('bottom-bar-toggle');
583+
584+
if (bottomBarHidden) {
585+
bottomBar.classList.add('hidden');
586+
toggleIcon.textContent = '▲';
587+
toggleButton.setAttribute('aria-expanded', 'false');
588+
} else {
589+
toggleButton.setAttribute('aria-expanded', 'true');
590+
}
591+
592+
toggleButton.addEventListener('click', toggleBottomBar);
593+
});
576594

577595
// Toggle bottom bar visibility
578596
const toggleBottomBar = () => {
579597
const bottomBar = document.querySelector('.reviews-bottom-bar');
580598
const toggleIcon = document.getElementById('toggle-icon');
599+
const toggleButton = document.getElementById('bottom-bar-toggle');
581600

582601
bottomBar.classList.toggle('hidden');
583602

584603
if (bottomBar.classList.contains('hidden')) {
585604
toggleIcon.textContent = '▲';
605+
toggleButton.setAttribute('aria-expanded', 'false');
586606
} else {
587607
toggleIcon.textContent = '▼';
608+
toggleButton.setAttribute('aria-expanded', 'true');
588609
}
589610

590611
// Save preference in localStorage
591-
localStorage.setItem('bottomBarHidden', bottomBar.classList.contains('hidden'));
612+
localStorage.setItem('grantsBottomBarHidden', bottomBar.classList.contains('hidden'));
592613
};
593-
594-
// Restore bottom bar state from localStorage
595-
window.addEventListener('load', () => {
596-
const bottomBarHidden = localStorage.getItem('bottomBarHidden') === 'true';
597-
const bottomBar = document.querySelector('.reviews-bottom-bar');
598-
const toggleIcon = document.getElementById('toggle-icon');
599-
const toggleButton = document.getElementById('bottom-bar-toggle');
600-
601-
if (bottomBarHidden) {
602-
bottomBar.classList.add('hidden');
603-
toggleIcon.textContent = '▲';
604-
}
605-
606-
toggleButton.addEventListener('click', toggleBottomBar);
607-
});
608614
</script>
609615
<ul class="object-tools">
610616
<li>
@@ -972,8 +978,8 @@ <h2 class="current-grants-num">
972978
</div>
973979
</div>
974980
{% endif %}
975-
<button type="button" class="reviews-bottom-bar-toggle" id="bottom-bar-toggle" title="Toggle bottom bar visibility">
976-
<span id="toggle-icon"></span>
981+
<button type="button" class="reviews-bottom-bar-toggle" id="bottom-bar-toggle" aria-label="Toggle bottom bar visibility" aria-expanded="true">
982+
<span id="toggle-icon" aria-hidden="true"></span>
977983
</button>
978984
</form>
979985
{% endblock %}

backend/reviews/templates/proposals-recap.html

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,22 @@
192192
getRefs();
193193
updateBottomBarUI();
194194

195+
// Initialize bottom bar toggle functionality
196+
const bottomBarHidden = localStorage.getItem('proposalsBottomBarHidden') === 'true';
197+
const bottomBar = document.querySelector('.reviews-bottom-bar');
198+
const toggleIcon = document.getElementById('toggle-icon');
199+
const toggleButton = document.getElementById('bottom-bar-toggle');
200+
201+
if (bottomBarHidden) {
202+
bottomBar.classList.add('hidden');
203+
toggleIcon.textContent = '▲';
204+
toggleButton.setAttribute('aria-expanded', 'false');
205+
} else {
206+
toggleButton.setAttribute('aria-expanded', 'true');
207+
}
208+
209+
toggleButton.addEventListener('click', toggleBottomBar);
210+
195211
submissions.forEach((submissionData) => {
196212
const submissionId = submissionData.id;
197213
const acceptInput = document.getElementById(
@@ -365,33 +381,21 @@
365381
const toggleBottomBar = () => {
366382
const bottomBar = document.querySelector('.reviews-bottom-bar');
367383
const toggleIcon = document.getElementById('toggle-icon');
384+
const toggleButton = document.getElementById('bottom-bar-toggle');
368385

369386
bottomBar.classList.toggle('hidden');
370387

371388
if (bottomBar.classList.contains('hidden')) {
372389
toggleIcon.textContent = '▲';
390+
toggleButton.setAttribute('aria-expanded', 'false');
373391
} else {
374392
toggleIcon.textContent = '▼';
393+
toggleButton.setAttribute('aria-expanded', 'true');
375394
}
376395

377396
// Save preference in localStorage
378-
localStorage.setItem('bottomBarHidden', bottomBar.classList.contains('hidden'));
397+
localStorage.setItem('proposalsBottomBarHidden', bottomBar.classList.contains('hidden'));
379398
};
380-
381-
// Restore bottom bar state from localStorage
382-
window.addEventListener('load', () => {
383-
const bottomBarHidden = localStorage.getItem('bottomBarHidden') === 'true';
384-
const bottomBar = document.querySelector('.reviews-bottom-bar');
385-
const toggleIcon = document.getElementById('toggle-icon');
386-
const toggleButton = document.getElementById('bottom-bar-toggle');
387-
388-
if (bottomBarHidden) {
389-
bottomBar.classList.add('hidden');
390-
toggleIcon.textContent = '▲';
391-
}
392-
393-
toggleButton.addEventListener('click', toggleBottomBar);
394-
});
395399
</script>
396400

397401
<form id="changelist-form" method="post" novalidate="">
@@ -659,8 +663,8 @@ <h2>Waiting List: <span id="waitinglist-proposals-num">0</span></h2>
659663
</div>
660664
</div>
661665
</div>
662-
<button type="button" class="reviews-bottom-bar-toggle" id="bottom-bar-toggle" title="Toggle bottom bar visibility">
663-
<span id="toggle-icon"></span>
666+
<button type="button" class="reviews-bottom-bar-toggle" id="bottom-bar-toggle" aria-label="Toggle bottom bar visibility" aria-expanded="true">
667+
<span id="toggle-icon" aria-hidden="true"></span>
664668
</button>
665669
</form>
666670
{% endblock %}

0 commit comments

Comments
 (0)