From 3247b1108fd72a8fc4483f8ae29b5b28273e33f3 Mon Sep 17 00:00:00 2001 From: Antoine M Date: Tue, 2 Apr 2024 16:34:58 +0200 Subject: [PATCH] aria pressed for active filter + sr-only indication for active filter button --- resources/js/archive-template-publications.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/resources/js/archive-template-publications.js b/resources/js/archive-template-publications.js index 4d63673..58578e5 100644 --- a/resources/js/archive-template-publications.js +++ b/resources/js/archive-template-publications.js @@ -73,6 +73,7 @@ function toggleActivePublicationTypeFilterButton() { filterButtons.forEach((button) => { button.classList.remove('filters-toolbar__action-button--active'); + button.setAttribute('aria-pressed', 'false'); }); const correspondingActiveThematiqueButton = document.querySelector( @@ -81,6 +82,7 @@ function toggleActivePublicationTypeFilterButton() { if (!correspondingActiveThematiqueButton) return; correspondingActiveThematiqueButton.classList.add('filters-toolbar__action-button--active'); + correspondingActiveThematiqueButton.setAttribute('aria-pressed', 'true'); } function updateActiveThematiquesFiltersViewer() { const activeFilters = document.querySelectorAll( @@ -106,7 +108,15 @@ function updateActiveThematiquesFiltersViewer() { activeFilters.forEach((activeFilterCheckbox) => { const button = document.createElement('button'); button.classList.add('filters-toolbar__action-button--active-filter-remover'); - button.innerText = activeFilterCheckbox.getAttribute('data-title'); + + const span = document.createElement('span'); + span.classList.add('sr-only'); + span.innerText = mainAppJsDynamicDatas.deleteFilter + ' :'; + button.appendChild(span); + + const buttonText = document.createTextNode(activeFilterCheckbox.getAttribute('data-title')); + button.appendChild(buttonText); + button.setAttribute('value', activeFilterCheckbox.getAttribute('value')); activeFiltersContainer.appendChild(button);