diff --git a/src/components/autocomplete/autocomplete.spec.js b/src/components/autocomplete/autocomplete.spec.js index dcc8f23cfa7..87bc79a2b80 100644 --- a/src/components/autocomplete/autocomplete.spec.js +++ b/src/components/autocomplete/autocomplete.spec.js @@ -98,6 +98,31 @@ describe('', function() { element.remove(); })); + it('should allow receiving focus on the autocomplete', function() { + var scope = createScope(null, {inputId: 'custom-input-id'}); + var template = '\ + \ + {{item.display}}\ + '; + var element = compile(template, scope); + var focusSpy = jasmine.createSpy('focus'); + + document.body.appendChild(element[0]); + + element.on('focus', focusSpy); + + element.focus(); + + expect(focusSpy).toHaveBeenCalled(); + }); + it('should allow you to set an input id without floating label', inject(function() { var scope = createScope(null, {inputId: 'custom-input-id'}); var template = '\ diff --git a/src/components/autocomplete/js/autocompleteDirective.js b/src/components/autocomplete/js/autocompleteDirective.js index 7d60117cc2b..7ed3e7aaec9 100644 --- a/src/components/autocomplete/js/autocompleteDirective.js +++ b/src/components/autocomplete/js/autocompleteDirective.js @@ -156,9 +156,7 @@ function MdAutocomplete () { // Set our variable for the link function above which runs later hasNotFoundTemplate = noItemsTemplate ? true : false; - if (attr.hasOwnProperty('tabindex')) { - element.attr('tabindex', '-1'); - } + element.attr('tabindex', '-1'); return '\