Skip to content

Commit

Permalink
fix(storefront): BCTHEME-423 Search result on search page not notifie…
Browse files Browse the repository at this point in the history
…d by screen reader (#2024)
  • Loading branch information
yurytut1993 authored Apr 30, 2021
1 parent 6dcc333 commit 6e4c844
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
12 changes: 9 additions & 3 deletions assets/js/theme/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,15 @@ export default class Search extends CatalogPage {
}
});

setTimeout(() => {
$('[data-search-aria-message]').removeClass('u-hidden');
}, 100);
const $searchResultsMessage = $(`<p
class="aria-description--hidden"
tabindex="-1"
role="status"
aria-live="polite"
>${this.context.searchResultsCount}</p>`)
.prependTo('body');

setTimeout(() => $searchResultsMessage.focus(), 100);
}

loadTreeNodes(node, cb) {
Expand Down
9 changes: 1 addition & 8 deletions templates/pages/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
---
{{inject 'categoryTree' forms.search.category_options}}
{{inject 'searchProductsPerPage' theme_settings.searchpage_products_per_page}}
{{inject 'searchResultsCount' (lang 'search.results.count' count=result_count search_query=(sanitize forms.search.query))}}
{{#partial "head"}}
{{#if pagination.product_results.previous}}
<link rel="prev" href="{{pagination.product_results.previous}}">
Expand Down Expand Up @@ -125,14 +126,6 @@ <h5 class="suggestion-title">{{lang 'forms.search.suggestions.title'}}</h5>
</div>
{{/if}}

<p role="status"
aria-live="polite"
class="quickSearchResultsAriaMessage aria-description--hidden u-hidden"
data-search-aria-message
>
{{{lang 'search.results.count' count=result_count search_query=(sanitize forms.search.query)}}}
</p>

<div role="tabpanel" id="search-results-content" aria-labelledby="search-results-content-count" {{#if forms.search.section '!=' 'content'}}class="u-hidden"{{/if}}>
{{> components/search/content-listing}}
</div>
Expand Down

0 comments on commit 6e4c844

Please sign in to comment.