A11Y: Add aria-labels to search inputs and search button (#11752)

This commit is contained in:
Kris 2021-01-19 14:32:32 -05:00 committed by GitHub
parent e6bbe9b5df
commit e968af6dd4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 5 deletions

View File

@ -1,6 +1,6 @@
<div>
<form action="//google.com/search" id="google-search">
<input type="text" name="q" value={{searchTerm}}>
<input type="text" name="q" aria-label={{i18n "search.search_google"}} value={{searchTerm}}>
<input name="as_sitesearch" value={{siteUrl}} type="hidden">
<button class="btn btn-primary" type="submit">{{i18n "search.search_google_button"}}</button>
</form>

View File

@ -4,8 +4,8 @@
<div class="search-advanced">
{{#unless site.mobileView}}
<div class="search-bar">
{{search-text-field value=searchTerm class="full-page-search search no-blur search-query" enter=(action "search") hasAutofocus=hasAutofocus}}
{{d-button action=(action "search") icon="search" class="btn-primary search-cta" disabled=searchButtonDisabled}}
{{search-text-field value=searchTerm class="full-page-search search no-blur search-query" aria-label=(i18n "search.full_page_title") enter=(action "search") hasAutofocus=hasAutofocus}}
{{d-button action=(action "search") icon="search" class="btn-primary search-cta" ariaLabel="search.search_button" disabled=searchButtonDisabled}}
</div>
{{/unless}}
@ -193,7 +193,7 @@
{{#if site.mobileView}}
<div class="search-bar">
{{search-text-field value=searchTerm class="full-page-search search no-blur search-query" enter=(action "search") hasAutofocus=hasAutofocus}}
{{d-button action=(action "search") icon="search" class="btn-primary search-cta" disabled=searchButtonDisabled}}
{{d-button action=(action "search") icon="search" class="btn-primary search-cta" ariaLabel="search.search_button" disabled=searchButtonDisabled}}
</div>
{{/if}}

View File

@ -23,6 +23,7 @@ createWidget("search-term", {
value: attrs.value || "",
autocomplete: "discourse",
placeholder: attrs.contextEnabled ? "" : I18n.t("search.title"),
"aria-label": I18n.t("search.title"),
};
},

View File

@ -567,7 +567,7 @@ en:
other: "You have <strong>%{count}</strong> posts pending."
ok: "OK"
example_username: "username"
reject_reason:
reject_reason:
title: "Why are you rejecting this user?"
send_email: "Send rejection email"
@ -2108,6 +2108,7 @@ en:
or_search_google: "Or try searching with Google instead:"
search_google: "Try searching with Google instead:"
search_google_button: "Google"
search_button: "Search"
context:
user: "Search posts by @%{username}"