Skip to content

Commit

Permalink
Make search bar and results more accessible
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
smythp committed Sep 26, 2023
1 parent 62c403a commit 34410eb
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 this site. After typing, navigate to results with the tab key and select your result with the Enter key."

- 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="polite">
<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 34410eb

Please sign in to comment.