fix(typeahead): fix programmatic focus issue

- Fix issue where programmatic focus on typeahead input does not work

Closes #5150
Fixes #764
This commit is contained in:
Chenyu Zhang
2016-01-05 18:27:04 -05:00
committed by Wesley Cho
parent ff5e720690
commit cab0945ac9
2 changed files with 4 additions and 1 deletions
+1
View File
@@ -1337,6 +1337,7 @@ describe('typeahead tests', function() {
var element = prepareInputEl('<div><input ng-model="result" uib-typeahead="item for item in source | filter:$viewValue" typeahead-min-length="0"></div>');
var inputEl = findInput(element);
inputEl.focus();
$timeout.flush();
$scope.$digest();
expect(element).toBeOpenWithActive(3, 0);
});
+3 -1
View File
@@ -407,7 +407,9 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.debounce', 'ui.bootstrap
element.bind('focus', function () {
hasFocus = true;
if (minLength === 0 && !modelCtrl.$viewValue) {
getMatchesAsync(modelCtrl.$viewValue);
$timeout(function() {
getMatchesAsync(modelCtrl.$viewValue);
}, 0);
}
});