@@ -1233,12 +1233,15 @@ describe('ui-select tests', function() {
1233
1233
if ( attrs . closeOnSelect !== undefined ) { attrsHtml += ' close-on-select="' + attrs . closeOnSelect + '"' ; }
1234
1234
if ( attrs . tagging !== undefined ) { attrsHtml += ' tagging="' + attrs . tagging + '"' ; }
1235
1235
if ( attrs . taggingTokens !== undefined ) { attrsHtml += ' tagging-tokens="' + attrs . taggingTokens + '"' ; }
1236
+ if ( attrs . firstItemActive === undefined ) { attrs . firstItemActive = true ; }
1237
+ } else {
1238
+ attrs = { firstItemActive : true } ;
1236
1239
}
1237
1240
1238
1241
return compileTemplate (
1239
1242
'<ui-select multiple ng-model="selection.selectedMultiple"' + attrsHtml + ' theme="bootstrap" style="width: 800px;"> \
1240
1243
<ui-select-match placeholder="Pick one...">{{$item.name}} <{{$item.email}}></ui-select-match> \
1241
- <ui-select-choices repeat="person in people | filter: $select.search" first-item-active="true "> \
1244
+ <ui-select-choices repeat="person in people | filter: $select.search" first-item-active="' + attrs . firstItemActive + ' "> \
1242
1245
<div ng-bind-html="person.name | highlight: $select.search"></div> \
1243
1246
<div ng-bind-html="person.email | highlight: $select.search"></div> \
1244
1247
</ui-select-choices> \
@@ -1505,12 +1508,31 @@ describe('ui-select tests', function() {
1505
1508
var searchInput = el . find ( '.ui-select-search' ) ;
1506
1509
1507
1510
triggerKeydown ( searchInput , Key . Down ) ; //Open dropdown
1508
- el . scope ( ) . $select . activeIndex = 0
1511
+ el . scope ( ) . $select . activeIndex = 0 ;
1509
1512
1510
- triggerKeydown ( searchInput , Key . Down )
1511
- triggerKeydown ( searchInput , Key . Enter )
1513
+ triggerKeydown ( searchInput , Key . Down ) ;
1514
+ triggerKeydown ( searchInput , Key . Enter ) ;
1512
1515
expect ( scope . selection . selectedMultiple . length ) . toEqual ( 2 ) ;
1516
+ } ) ;
1517
+
1518
+ it ( 'should close choices on ENTER when firstItemActive set to false' , function ( ) {
1519
+
1520
+ scope . selection . selectedMultiple = [ scope . people [ 5 ] ] ; //Samantha
1521
+ var el = createUiSelectMultiple ( { firstItemActive : false } ) ;
1522
+ var searchInput = el . find ( '.ui-select-search' ) ;
1523
+
1524
+ triggerKeydown ( searchInput , Key . Enter ) ;
1525
+ expect ( el . scope ( ) . $select . open ) . toEqual ( false ) ;
1526
+ } ) ;
1527
+
1528
+ it ( 'should close choices on TAB when firstItemActive set to false' , function ( ) {
1529
+
1530
+ scope . selection . selectedMultiple = [ scope . people [ 5 ] ] ; //Samantha
1531
+ var el = createUiSelectMultiple ( { firstItemActive : false } ) ;
1532
+ var searchInput = el . find ( '.ui-select-search' ) ;
1513
1533
1534
+ triggerKeydown ( searchInput , Key . Tab ) ;
1535
+ expect ( el . scope ( ) . $select . open ) . toEqual ( false ) ;
1514
1536
} ) ;
1515
1537
1516
1538
it ( 'should increase $select.activeIndex when pressing DOWN key from dropdown' , function ( ) {
0 commit comments