@@ -64,10 +64,14 @@ describe('typeahead tests', function() {
64
64
return findDropDown ( element ) . find ( 'li' ) ;
65
65
} ;
66
66
67
- var triggerKeyDown = function ( element , keyCode ) {
67
+ var triggerKeyDown = function ( element , keyCode , options ) {
68
+ options = options || { } ;
68
69
var inputEl = findInput ( element ) ;
69
70
var e = $ . Event ( 'keydown' ) ;
70
71
e . which = keyCode ;
72
+ if ( options . shiftKey ) {
73
+ e . shiftKey = true ;
74
+ }
71
75
inputEl . trigger ( e ) ;
72
76
} ;
73
77
@@ -1351,6 +1355,23 @@ describe('typeahead tests', function() {
1351
1355
expect ( element ) . toBeClosed ( ) ;
1352
1356
} ) ;
1353
1357
1358
+ it ( "should not capture tab when shift key is pressed" , function ( ) {
1359
+ $scope . select_count = 0 ;
1360
+ $scope . onSelect = function ( $item , $model , $label ) {
1361
+ $scope . select_count = $scope . select_count + 1 ;
1362
+ } ;
1363
+ var element = prepareInputEl ( '<div><input ng-model="result" ng-keydown="keyDownEvent = $event" uib-typeahead="item for item in source | filter:$viewValue" typeahead-on-select="onSelect($item, $model, $label)" typeahead-focus-first="false"></div>' ) ;
1364
+ changeInputValueTo ( element , 'b' ) ;
1365
+
1366
+ // down key should be captured and focus first element
1367
+ triggerKeyDown ( element , 40 ) ;
1368
+
1369
+ triggerKeyDown ( element , 9 , { shiftKey : true } ) ;
1370
+ expect ( $scope . keyDownEvent . isDefaultPrevented ( ) ) . toBeFalsy ( ) ;
1371
+ expect ( $scope . select_count ) . toEqual ( 0 ) ;
1372
+ expect ( element ) . toBeClosed ( ) ;
1373
+ } ) ;
1374
+
1354
1375
it ( 'should capture enter or tab when an item is focused' , function ( ) {
1355
1376
$scope . select_count = 0 ;
1356
1377
$scope . onSelect = function ( $item , $model , $label ) {
0 commit comments