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

Commit 0149eff

Browse files
committedOct 8, 2013
fix(typeahead): fix loading callback when deleting characters
Closes #1140
1 parent 0cdc460 commit 0149eff

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed
 

‎src/typeahead/test/typeahead.spec.js

+22
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,28 @@ describe('typeahead tests', function () {
416416
expect(element).toBeClosed();
417417
});
418418

419+
it('issue 1140 - should properly update loading callback when deleting characters', function () {
420+
421+
$scope.items = function(viewValue) {
422+
return $timeout(function(){
423+
return [viewValue];
424+
});
425+
};
426+
var element = prepareInputEl("<div><input ng-model='result' typeahead-min-length='2' typeahead-loading='isLoading' typeahead='item for item in items($viewValue)'></div>");
427+
var inputEl = findInput(element);
428+
429+
changeInputValueTo(element, 'match');
430+
$scope.$digest();
431+
432+
expect($scope.isLoading).toBeTruthy();
433+
434+
changeInputValueTo(element, 'm');
435+
$timeout.flush();
436+
$scope.$digest();
437+
438+
expect($scope.isLoading).toBeFalsy();
439+
});
440+
419441
it('does not close matches popup on click in input', function () {
420442
var element = prepareInputEl("<div><input ng-model='result' typeahead='item for item in source | filter:$viewValue'></div>");
421443
var inputEl = findInput(element);

‎src/typeahead/typeahead.js

+1
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap
160160
getMatchesAsync(inputValue);
161161
}
162162
} else {
163+
isLoadingSetter(originalScope, false);
163164
resetMatches();
164165
}
165166

0 commit comments

Comments
 (0)
This repository has been archived.