1
0
Fork 0

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

* fix: search input a11y issue

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

* update test
This commit is contained in:
Endi 2019-05-13 20:15:38 +07:00 committed by Sylvain Pace
parent c0e9e19b9f
commit 59d21f5e19
2 changed files with 5 additions and 1 deletions

View file

@ -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';

View file

@ -175,6 +175,7 @@ describe('DocSearch', () => {
debug: false,
cssClasses: { prefix: 'ds' },
anOption: 44,
ariaLabel: 'search input',
});
});
it('should instantiate algoliasearch with the correct values', () => {
@ -217,6 +218,7 @@ describe('DocSearch', () => {
anOption: '44',
cssClasses: { prefix: 'ds' },
debug: false,
ariaLabel: 'search input'
})
).toBe(true);
});