fix(v2): docsearch a11y issue (#1449)

This commit is contained in:
Endi 2019-05-11 22:47:22 +07:00 committed by Yangshun Tay
parent 6136fbe1d2
commit 070723697f
4 changed files with 12 additions and 6 deletions

View file

@ -28,6 +28,11 @@ class Search extends React.Component {
// https://github.com/algolia/docsearch/issues/352
const isClient = typeof window !== 'undefined';
if (isClient) {
// Temporary workaround for a11y issue
// https://github.com/algolia/docsearch/issues/418#
const docsearchInput = document.querySelector('#search_input_react');
const ariaLabel = docsearchInput.getAttribute('aria-label');
import('docsearch.js').then(({default: docsearch}) => {
docsearch({
appId: algolia.appId,
@ -36,6 +41,7 @@ class Search extends React.Component {
inputSelector: '#search_input_react',
algoliaOptions: algolia.algoliaOptions,
});
docsearchInput.setAttribute('aria-label', ariaLabel);
});
} else {
console.warn('Search has failed to load and now is being disabled');