This repository has been archived by the owner on May 29, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(typeahead): don't show matches if an element is not focused
Closes #964
- Loading branch information
1 parent
c6ba8d7
commit d1f9453
Showing
2 changed files
with
30 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
describe('typeahead tests', function () { | ||
|
||
var $scope, $compile, $document; | ||
var $scope, $compile, $document, $timeout; | ||
var changeInputValueTo; | ||
|
||
beforeEach(module('ui.bootstrap.typeahead')); | ||
|
@@ -18,7 +18,7 @@ describe('typeahead tests', function () { | |
}; | ||
}); | ||
})); | ||
beforeEach(inject(function (_$rootScope_, _$compile_, _$document_, $sniffer) { | ||
beforeEach(inject(function (_$rootScope_, _$compile_, _$document_, _$timeout_, $sniffer) { | ||
$scope = _$rootScope_; | ||
$scope.source = ['foo', 'bar', 'baz']; | ||
$scope.states = [ | ||
|
@@ -27,6 +27,7 @@ describe('typeahead tests', function () { | |
]; | ||
$compile = _$compile_; | ||
$document = _$document_; | ||
$timeout = _$timeout_; | ||
changeInputValueTo = function (element, value) { | ||
var inputEl = findInput(element); | ||
inputEl.val(value); | ||
|
@@ -396,6 +397,25 @@ describe('typeahead tests', function () { | |
expect(inputEl.val()).toEqual('[email protected]'); | ||
}); | ||
|
||
it('issue 964 - should not show popup with matches if an element is not focused', function () { | ||
|
||
$scope.items = function(viewValue) { | ||
return $timeout(function(){ | ||
return [viewValue]; | ||
}); | ||
}; | ||
var element = prepareInputEl("<div><input ng-model='result' typeahead='item for item in items($viewValue)'></div>"); | ||
var inputEl = findInput(element); | ||
|
||
changeInputValueTo(element, 'match'); | ||
$scope.$digest(); | ||
|
||
inputEl.blur(); | ||
$timeout.flush(); | ||
|
||
expect(element).toBeClosed(); | ||
}); | ||
|
||
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); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters