Skip to content

Commit

Permalink
fix: docsearch input should have aria-label (a11y) (#687)
Browse files Browse the repository at this point in the history
* fix: search input a11y issue

* fix: docsearch input should have aria-label (a11y)

* update test
  • Loading branch information
endiliey authored and Sylvain Pace committed May 13, 2019
1 parent c0e9e19 commit 59d21f5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/lib/DocSearch.js
Expand Up @@ -80,7 +80,9 @@ class DocSearch {
this.autocompleteOptions.cssClasses || {};
this.autocompleteOptions.cssClasses.prefix =
this.autocompleteOptions.cssClasses.prefix || 'ds';

const inputAriaLabel = this.input && typeof this.input.attr === 'function' && this.input.attr('aria-label');
this.autocompleteOptions.ariaLabel =
this.autocompleteOptions.ariaLabel || inputAriaLabel || "search input";

this.isSimpleLayout = layout === 'simple';

Expand Down
2 changes: 2 additions & 0 deletions src/lib/__tests__/DocSearch-test.js
Expand Up @@ -175,6 +175,7 @@ describe('DocSearch', () => {
debug: false,
cssClasses: { prefix: 'ds' },
anOption: 44,
ariaLabel: 'search input',
});
});
it('should instantiate algoliasearch with the correct values', () => {
Expand Down Expand Up @@ -217,6 +218,7 @@ describe('DocSearch', () => {
anOption: '44',
cssClasses: { prefix: 'ds' },
debug: false,
ariaLabel: 'search input'
})
).toBe(true);
});
Expand Down

0 comments on commit 59d21f5

Please sign in to comment.