Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(storefront): BCTHEME-423 Search result on search page not notified by screen reader #2024

Merged
merged 1 commit into from
Apr 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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