Skip to content

Commit

Permalink
Make search bar and results more accessible (#255)
Browse files Browse the repository at this point in the history
* Make search bar and results more accessible

Added information on how to navigate to results in the aria-label
attribute on the search bar

Added a new field to English internationalization with instructions on
how to navigate to search results. This field will appear via the
aria-label to screen reader users.

Added an enclosing div informing screen readers to update when the
search results populate.

Signed-off-by: Patrick Smyth <[email protected]>

* Shortened aria-label for search, added search role

Made label instructing how to access search results less verbose

Signed-off-by: Patrick Smyth <[email protected]>

* Moved search role to form

Signed-off-by: Patrick Smyth <[email protected]>

* Changed aria label to include the word search

After testing, we found it better to include the word search.

Signed-off-by: Patrick Smyth <[email protected]>

* Changed aria-live from polite to assertive

Signed-off-by: Patrick Smyth <[email protected]>

---------

Signed-off-by: Patrick Smyth <[email protected]>
  • Loading branch information
smythp authored Oct 16, 2023
1 parent f050f54 commit 813f020
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions i18n/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
- id: search-text
translation: "Search"

- id: search-aria-label
translation: "Search. Press tab to navigate to search results"

- id: 404-title
translation: "404 — Page not found."

Expand Down
7 changes: 5 additions & 2 deletions layouts/partials/header/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,13 @@ <h2 class="h5 offcanvas-title ps-2" id="offcanvasDoksLabel"><a class="text-dark"

{{ if $showFlexSearch -}}
<hr class="text-black-50 my-4 d-lg-none">
<form class="doks-search position-relative flex-grow-1 ms-lg-auto me-lg-2">
<input id="search" class="form-control is-search" type="search" placeholder="{{ i18n "search-text" }}" aria-label="{{ i18n "search-text" }}" autocomplete="off">

<div role="region" aria-live="assertive">
<form class="doks-search position-relative flex-grow-1 ms-lg-auto me-lg-2">
<input id="search" class="form-control is-search" type="search" placeholder="{{ i18n "search-text" }}" aria-label="{{ i18n "search-aria-label" }}" autocomplete="off">
<div id="suggestions" class="shadow bg-white rounded d-none"></div>
</form>
</div>
{{ end -}}

<hr class="text-black-50 my-4 d-lg-none">
Expand Down

0 comments on commit 813f020

Please sign in to comment.