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 loading callback when deleting characters
Browse files Browse the repository at this point in the history
Closes #1140
  • Loading branch information
pkozlowski-opensource committed Oct 8, 2013
1 parent 0cdc460 commit 0149eff
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/typeahead/test/typeahead.spec.js
Expand Up @@ -416,6 +416,28 @@ describe('typeahead tests', function () {
expect(element).toBeClosed();
});

it('issue 1140 - should properly update loading callback when deleting characters', function () {

$scope.items = function(viewValue) {
return $timeout(function(){
return [viewValue];
});
};
var element = prepareInputEl("<div><input ng-model='result' typeahead-min-length='2' typeahead-loading='isLoading' typeahead='item for item in items($viewValue)'></div>");
var inputEl = findInput(element);

changeInputValueTo(element, 'match');
$scope.$digest();

expect($scope.isLoading).toBeTruthy();

changeInputValueTo(element, 'm');
$timeout.flush();
$scope.$digest();

expect($scope.isLoading).toBeFalsy();
});

it('does not close matches popup on click in input', function () {
var element = prepareInputEl("<div><input ng-model='result' typeahead='item for item in source | filter:$viewValue'></div>");
var inputEl = findInput(element);
Expand Down
1 change: 1 addition & 0 deletions src/typeahead/typeahead.js
Expand Up @@ -160,6 +160,7 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap
getMatchesAsync(inputValue);
}
} else {
isLoadingSetter(originalScope, false);
resetMatches();
}

Expand Down

0 comments on commit 0149eff

Please sign in to comment.