Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Commit

Permalink
fix(typeahead): fix programmatic focus issue
Browse files Browse the repository at this point in the history
- Fix issue where programmatic focus on typeahead input does not work

Closes #5150
Fixes #764
  • Loading branch information
chenyuzhcy authored and wesleycho committed Jan 6, 2016
1 parent ff5e720 commit cab0945
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/typeahead/test/typeahead.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down
4 changes: 3 additions & 1 deletion src/typeahead/typeahead.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});

Expand Down

0 comments on commit cab0945

Please sign in to comment.