Skip to content

Commit dcc4a74

Browse files
committed
Accessibility enhancements for Lunr search form
1 parent b717df6 commit dcc4a74

File tree

4 files changed

+9
-2
lines changed

4 files changed

+9
-2
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

8+
## Unreleased
9+
10+
### Added
11+
- Accessibility enhancements for Lunr search form.
12+
813
## [1.3.1] - 2018-02-16
914

1015
### Changed

_data/theme.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ t:
99
skip_footer: "Skip to footer"
1010
menu: "Menu"
1111
search: "Search"
12+
site_search: "Site Search"
1213
results_found: "Result(s) found"
1314
search_placeholder_text: "Enter your search term..."
1415
home: "Home"

_includes/search-form.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
{%- assign search_provider = site.search_provider | default: "lunr" -%}
44
{%- case search_provider -%}
55
{%- when "lunr" -%}
6-
<input type="text" id="search" class="search-input" tabindex="-1" placeholder="{{ site.data.theme.t.menu.search_placeholder_text | default: 'Enter your search term...' }}" />
6+
<label class="visually-hidden" for="search">{{ site.data.theme.t.site_search | default: 'Site Search' }}</label>
7+
<input type="text" id="search" class="search-input" aria-describedby="results-count" tabindex="-1" placeholder="{{ site.data.theme.t.menu.search_placeholder_text | default: 'Enter your search term...' }}" />
78
<div id="results" class="results"></div>
89
{%- when "algolia" -%}
910
<div tabindex="-1" class="search-searchbar"></div>

_includes/search/lunr-search-scripts.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
})
8989
});
9090
resultdiv.empty();
91-
resultdiv.prepend('<p class="results-found">' + result.length + ' {{ site.data.theme.t.menu.results_found | default: "Result(s) found" }}</p>');
91+
resultdiv.prepend('<p id="results-count" class="results-found">' + result.length + ' {{ site.data.theme.t.menu.results_found | default: "Result(s) found" }}</p>');
9292
for (var item in result) {
9393
var ref = result[item].ref;
9494
var searchitem =

0 commit comments

Comments
 (0)