Skip to content

Commit 7f58709

Browse files
committed
Select first option no mater if it creates new tag or offer existing one. Addresses issue angular-ui#1911
1 parent 3642a1d commit 7f58709

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

src/uiSelectController.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -569,11 +569,10 @@ uis.controller('uiSelectCtrl',
569569
}
570570
break;
571571
case KEY.UP:
572-
var minActiveIndex = (ctrl.search.length === 0 && ctrl.tagging.isActivated) ? -1 : 0;
573572
if (!ctrl.open && ctrl.multiple) ctrl.activate(false, true); //In case its the search input in 'multiple' mode
574-
else if (ctrl.activeIndex > minActiveIndex) {
573+
else if (ctrl.activeIndex > 0) {
575574
var idxmin = --ctrl.activeIndex;
576-
while(_isItemDisabled(ctrl.items[idxmin]) && idxmin > minActiveIndex) {
575+
while(_isItemDisabled(ctrl.items[idxmin]) && idxmin > 0) {
577576
ctrl.activeIndex = --idxmin;
578577
}
579578
}

test/select.spec.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2861,7 +2861,7 @@ describe('ui-select tests', function() {
28612861
triggerKeydown(searchInput, Key.Down);
28622862
expect(el.scope().$select.activeIndex).toBe(2);
28632863
triggerKeydown(searchInput, Key.Up);
2864-
expect(el.scope().$select.activeIndex).toBe(-1);
2864+
expect(el.scope().$select.activeIndex).toBe(0);
28652865
});
28662866

28672867
it('should ignored disabled items going down', function() {
@@ -2882,7 +2882,7 @@ describe('ui-select tests', function() {
28822882
triggerKeydown(searchInput, Key.Down);
28832883
expect(el.scope().$select.activeIndex).toBe(2);
28842884
triggerKeydown(searchInput, Key.Up);
2885-
expect(el.scope().$select.activeIndex).toBe(-1);
2885+
expect(el.scope().$select.activeIndex).toBe(0);
28862886
});
28872887

28882888
it('should ignore disabled items, going down with remove-selected on false', function() {
@@ -3231,12 +3231,12 @@ describe('ui-select tests', function() {
32313231
expect(el.scope().$select.spinnerClass).toBe('randomclass');
32323232
});
32333233
});
3234-
3234+
32353235
describe('With refresh on active', function(){
32363236
it('should refresh when is activated', function(){
32373237
scope.fetchFromServer = function(){};
32383238
var el = createUiSelect({refresh:"fetchFromServer($select.search)",refreshDelay:0});
3239-
spyOn(scope, 'fetchFromServer');
3239+
spyOn(scope, 'fetchFromServer');
32403240
expect(el.scope().$select.open).toEqual(false);
32413241
el.scope().$select.activate();
32423242
$timeout.flush();
@@ -3248,7 +3248,7 @@ describe('ui-select tests', function() {
32483248
it('should refresh when open is set to true', function(){
32493249
scope.fetchFromServer = function(){};
32503250
var el = createUiSelect({refresh:"fetchFromServer($select.search)",refreshDelay:0});
3251-
spyOn(scope, 'fetchFromServer');
3251+
spyOn(scope, 'fetchFromServer');
32523252
expect(el.scope().$select.open).toEqual(false);
32533253
openDropdown(el);
32543254
$timeout.flush();
@@ -3286,7 +3286,7 @@ describe('ui-select tests', function() {
32863286
triggerKeydown(searchInput, Key.Down);
32873287
expect(el.scope().$select.activeIndex).toBe(2);
32883288
triggerKeydown(searchInput, Key.Up);
3289-
expect(el.scope().$select.activeIndex).toBe(-1);
3289+
expect(el.scope().$select.activeIndex).toBe(0);
32903290
});
32913291

32923292
it('should ignored disabled items in the down direction with tagging on', function() {

0 commit comments

Comments
 (0)