A11Y: add live area for search menu, labels (#19061)

This commit is contained in:
Kris 2022-11-16 14:02:39 -05:00 committed by GitHub
parent d2a8884127
commit a5f2099884
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 1 deletions

View File

@ -90,6 +90,12 @@ function createSearchResult({ type, linkField, builder }) {
return createWidget(`search-result-${type}`, {
tagName: "ul.list",
buildAttributes() {
return {
"aria-label": `${type} ${I18n.t("search.results")}`,
};
},
html(attrs) {
return attrs.results.map((r) => {
let searchResultId;
@ -640,7 +646,13 @@ createWidget("search-menu-assistant-item", {
const attributes = {};
attributes.href = "#";
let content = [iconNode(attrs.icon || "search")];
let content = [
h(
"span",
{ attributes: { "aria-label": I18n.t("search.title") } },
iconNode(attrs.icon || "search")
),
];
if (prefix) {
content.push(h("span.search-item-prefix", `${prefix} `));

View File

@ -193,6 +193,12 @@ export default createWidget("search-menu", {
services: ["search"],
searchData,
buildAttributes() {
return {
"aria-live": "polite",
};
},
buildKey: () => "search-menu",
defaultState(attrs) {

View File

@ -2500,6 +2500,7 @@ en:
other: "<span>%{count}%{plus} results for</span><span class='term'>%{term}</span>"
title: "Search"
full_page_title: "Search"
results: "results"
no_results: "No results found."
no_more_results: "No more results found."
post_format: "#%{post_number} by %{username}"