Skip to content
Snippets Groups Projects
Unverified Commit 3005a466 authored by Alexis BENOIT's avatar Alexis BENOIT Committed by GitHub
Browse files

[a11y] Modification des tags de la recherche (#791)

parent e244f248
No related branches found
No related tags found
No related merge requests found
......@@ -48,10 +48,35 @@ class Search {
this.accessibleMessage = document.createElement('p');
this.accessibleMessageContainer.appendChild(this.accessibleMessage);
}
setTimeout(this.updateAccessibilityMessageRole.bind(this), speakDelay);
clearTimeout(this.a11yTimeout);
this.a11yTimeout = setTimeout(this.updateAccessibility.bind(this), speakDelay);
});
}
updateAccessibility () {
this.updateAccessibilityMessageRole();
this.updateAccessibilityTags();
}
updateAccessibilityTags () {
const results = this.element.querySelectorAll('.pagefind-ui__result');
results.forEach(this.updateAccessibilityResult);
}
updateAccessibilityResult (result) {
let image = result.querySelector('img'),
title = result.querySelector('.pagefind-ui__result-title');
if (image) {
image.setAttribute('alt', '');
}
if (title) {
title.setAttribute('role', 'heading');
title.setAttribute('aria-level', '2');
}
}
updateAccessibilityMessageRole () {
const message = this.element.querySelector('.pagefind-ui__message');
if (!message) {
......
......@@ -11,4 +11,5 @@
<button class="search__close" aria-label="{{ i18n "commons.search.close" }}">
{{ i18n "commons.search.close" }}
</button>
<p role="heading" aria-level="1" class="sr-only">{{ i18n "commons.search.title" }}</p>
</div>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment