@@ -863,7 +863,7 @@ describe('typeahead tests', function () {
863
863
} ) ;
864
864
} ) ;
865
865
866
- it ( 'should not capture enter or tab until an item is focused' , function ( ) {
866
+ it ( 'should not capture enter or tab when an item is not focused' , function ( ) {
867
867
$scope . select_count = 0 ;
868
868
$scope . onSelect = function ( $item , $model , $label ) {
869
869
$scope . select_count = $scope . select_count + 1 ;
@@ -876,10 +876,20 @@ describe('typeahead tests', function () {
876
876
expect ( $scope . keyDownEvent . isDefaultPrevented ( ) ) . toBeFalsy ( ) ;
877
877
expect ( $scope . select_count ) . toEqual ( 0 ) ;
878
878
879
- // tab key should not be captured when nothing is focused
879
+ // tab key should close the dropdown when nothing is focused
880
880
triggerKeyDown ( element , 9 ) ;
881
881
expect ( $scope . keyDownEvent . isDefaultPrevented ( ) ) . toBeFalsy ( ) ;
882
882
expect ( $scope . select_count ) . toEqual ( 0 ) ;
883
+ expect ( element ) . toBeClosed ( ) ;
884
+ } ) ;
885
+
886
+ it ( 'should capture enter or tab when an item is focused' , function ( ) {
887
+ $scope . select_count = 0 ;
888
+ $scope . onSelect = function ( $item , $model , $label ) {
889
+ $scope . select_count = $scope . select_count + 1 ;
890
+ } ;
891
+ var element = prepareInputEl ( '<div><input ng-model="result" ng-keydown="keyDownEvent = $event" typeahead="item for item in source | filter:$viewValue" typeahead-on-select="onSelect($item, $model, $label)" typeahead-focus-first="false"></div>' ) ;
892
+ changeInputValueTo ( element , 'b' ) ;
883
893
884
894
// down key should be captured and focus first element
885
895
triggerKeyDown ( element , 40 ) ;
0 commit comments