Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 98de313

Browse files
Jim Drurychukycheese
Jim Drury
authored andcommittedSep 18, 2023
Fixes aria issues on search form (mmistakes#2211)
* Fixes aria issues on search form * Swapping aria-label for <label> tag in search * Removing background gray caused by adding <form> tag to search * Removing redundant space * Making form not submit if key is enter Close mmistakes#2180
1 parent 7196bc3 commit 98de313

File tree

3 files changed

+28
-13
lines changed

3 files changed

+28
-13
lines changed
 

‎_data/ui-text.yml

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ en: &DEFAULT_EN
4646
comment_error_msg : "Sorry, there was an error with your submission. Please make sure all required fields have been completed and try again."
4747
loading_label : "Loading..."
4848
search_placeholder_text : "Enter your search term..."
49+
search_label_text : "Enter your search term..."
4950
results_found : "Result(s) found"
5051
back_to_top : "Back to top"
5152
en-US:

‎_includes/search/search_form.html

+21-13
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
11
<div class="search-content__inner-wrap">
2-
{%- assign search_provider = site.search_provider | default: "lunr" -%}
3-
{%- case search_provider -%}
2+
{%- assign search_provider = site.search_provider | default: "lunr" -%}
3+
{%- case search_provider -%}
44
{%- when "lunr" -%}
5-
<input type="search" id="search" aria-placeholder="{{ site.data.ui-text[site.locale].search_placeholder_text | default: 'Enter your search term...' }}" class="search-input" tabindex="-1" placeholder="{{ site.data.ui-text[site.locale].search_placeholder_text | default: 'Enter your search term...' }}" />
6-
<div id="results" class="results"></div>
5+
<form class="search-content__form" onkeydown="return event.key != 'Enter';">
6+
<label class="sr-only" for="search">
7+
{{ site.data.ui-text[site.locale].search_label_text | default: 'Enter your search term...' }}
8+
</label>
9+
<input type="search" id="search" class="search-input" tabindex="-1" placeholder="{{ site.data.ui-text[site.locale].search_placeholder_text | default: 'Enter your search term...' }}" />
10+
</form>
11+
<div id="results" class="results"></div>
712
{%- when "google" -%}
8-
<form onsubmit="return googleCustomSearchExecute();" id="cse-search-box-form-id">
9-
<input type="search" id="cse-search-input-box-id" aria-placeholder="{{ site.data.ui-text[site.locale].search_placeholder_text | default: 'Enter your search term...' }}" class="search-input" tabindex="-1" placeholder="{{ site.data.ui-text[site.locale].search_placeholder_text | default: 'Enter your search term...' }}" />
10-
</form>
11-
<div id="results" class="results">
12-
<gcse:searchresults-only></gcse:searchresults-only>
13-
</div>
13+
<form onsubmit="return googleCustomSearchExecute();" id="cse-search-box-form-id">
14+
<label class="sr-only" for="cse-search-input-box-id">
15+
{{ site.data.ui-text[site.locale].search_label_text | default: 'Enter your search term...' }}
16+
</label>
17+
<input type="search" id="cse-search-input-box-id" class="search-input" tabindex="-1" placeholder="{{ site.data.ui-text[site.locale].search_placeholder_text | default: 'Enter your search term...' }}" />
18+
</form>
19+
<div id="results" class="results">
20+
<gcse:searchresults-only></gcse:searchresults-only>
21+
</div>
1422
{%- when "algolia" -%}
15-
<div class="search-searchbar"></div>
16-
<div class="search-hits"></div>
17-
{%- endcase -%}
23+
<div class="search-searchbar"></div>
24+
<div class="search-hits"></div>
25+
{%- endcase -%}
1826
</div>

‎_sass/minimal-mistakes/_search.scss

+6
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@
5050
@include breakpoint($x-large) {
5151
max-width: $max-width;
5252
}
53+
54+
}
55+
56+
&__form {
57+
background-color: transparent;
5358
}
5459

5560
.search-input {
@@ -119,6 +124,7 @@
119124
font-style: normal;
120125
text-decoration: underline;
121126
}
127+
122128
.archive__item-excerpt .ais-Highlight {
123129
color: $primary-color;
124130
font-style: normal;

0 commit comments

Comments
 (0)
Please sign in to comment.