diff --git a/src/lib/DocSearch.js b/src/lib/DocSearch.js index 0bcd168da4..d469f53188 100644 --- a/src/lib/DocSearch.js +++ b/src/lib/DocSearch.js @@ -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'; diff --git a/src/lib/__tests__/DocSearch-test.js b/src/lib/__tests__/DocSearch-test.js index 541c9bbbe2..2fccb60faf 100644 --- a/src/lib/__tests__/DocSearch-test.js +++ b/src/lib/__tests__/DocSearch-test.js @@ -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); });