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(v2): docsearch a11y issue #1449

Merged
merged 1 commit into from
May 11, 2019
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
4 changes: 2 additions & 2 deletions packages/docusaurus-mdx-loader/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"@babel/parser": "^7.4.3",
"@babel/traverse": "^7.4.3",
"@mapbox/rehype-prism": "^0.3.1",
"@mdx-js/mdx": "^1.0.14",
"@mdx-js/react": "^1.0.6",
"@mdx-js/mdx": "^1.0.18",
"@mdx-js/react": "^1.0.16",
"github-slugger": "^1.2.1",
"loader-utils": "^1.2.3",
"mdast-util-to-string": "^1.0.5",
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-theme-search-algolia/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"license": "MIT",
"dependencies": {
"docsearch.js": "^2.5.2"
"docsearch.js": "^2.6.x"
},
"peerDependencies": {
"@docusaurus/core": "^2.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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');
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1599,7 +1599,7 @@
refractor "^2.3.0"
unist-util-visit "^1.1.3"

"@mdx-js/mdx@^1.0.14":
"@mdx-js/mdx@^1.0.18":
version "1.0.18"
resolved "https://registry.yarnpkg.com/@mdx-js/mdx/-/mdx-1.0.18.tgz#42bb35e36b7566aed88c5c11a381705f974bc03b"
integrity sha512-KO2odMrZC77Yf9bhL0Qu0GtvVivVV6dL5DWJeuMeSkc9wkL9fBT06re67TfgeJ37R+lyslkG+uPUahIj4/SOoQ==
Expand All @@ -1620,7 +1620,7 @@
unist-builder "^1.0.1"
unist-util-visit "^1.3.0"

"@mdx-js/react@^1.0.6":
"@mdx-js/react@^1.0.16":
version "1.0.16"
resolved "https://registry.yarnpkg.com/@mdx-js/react/-/react-1.0.16.tgz#414c3fce49493a4c60e5590cfc0a2a07efc19f38"
integrity sha512-HJJO8LYogt9UT4TP3+TVeokMj0lgwCONKlcOfr7VMb38Z6DDE3Ydvi+M3iScUea2DfifS4kGztgJ7zH6HXynTw==
Expand Down Expand Up @@ -4607,7 +4607,7 @@ dns-txt@^2.0.2:
dependencies:
buffer-indexof "^1.0.0"

docsearch.js@^2.5.2:
docsearch.js@^2.5.2, docsearch.js@^2.6.x:
version "2.6.2"
resolved "https://registry.yarnpkg.com/docsearch.js/-/docsearch.js-2.6.2.tgz#cb36a97aeac8a8d31eed5915cdee808a2248b41c"
integrity sha512-qyQ+raZlHSkfdpFg8wJNhjiz9WsjdQkRGe2LiiKS6vIIsouNNole2Kg/9UvGoUIK9PLLl31uL3I4YDwnrXt5yQ==
Expand Down