diff --git a/src/typeahead/test/typeahead.spec.js b/src/typeahead/test/typeahead.spec.js index 741621e65c..a86dcedd7e 100644 --- a/src/typeahead/test/typeahead.spec.js +++ b/src/typeahead/test/typeahead.spec.js @@ -842,4 +842,13 @@ describe('typeahead tests', function () { expect($scope.select_count).toEqual(1); }); + describe('minLength set to 0', function () { + it('should open typeahead if input is changed to empty string if defined threshold is 0', function () { + var element = prepareInputEl('
'); + changeInputValueTo(element, ''); + + expect(element).toBeOpenWithActive(3, 0); + }); + }); + }); diff --git a/src/typeahead/typeahead.js b/src/typeahead/typeahead.js index 1fe28401ab..dba444dcf1 100644 --- a/src/typeahead/typeahead.js +++ b/src/typeahead/typeahead.js @@ -41,7 +41,10 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap //SUPPORTED ATTRIBUTES (OPTIONS) //minimal no of characters that needs to be entered before typeahead kicks-in - var minSearch = originalScope.$eval(attrs.typeaheadMinLength) || 1; + var minLength = originalScope.$eval(attrs.typeaheadMinLength); + if (!minLength && minLength !== 0) { + minLength = 1; + } //minimal wait time after last character typed before typeahead kicks-in var waitTime = originalScope.$eval(attrs.typeaheadWaitMs) || 0; @@ -193,7 +196,7 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap hasFocus = true; - if (inputValue && inputValue.length >= minSearch) { + if (minLength === 0 || inputValue && inputValue.length >= minLength) { if (waitTime > 0) { cancelPreviousTimeout(); scheduleSearchWithTimeout(inputValue);