Skip to content
This repository has been archived by the owner on Oct 2, 2019. It is now read-only.

Commit

Permalink
Merge pull request #1915 from ilinsky/master
Browse files Browse the repository at this point in the history
Select first option no mater if it creates new tag or offers existing…
  • Loading branch information
Jefiozie authored Mar 5, 2018
2 parents 32645f4 + 8b2b4b7 commit d8fed30
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
5 changes: 2 additions & 3 deletions src/uiSelectController.js
Original file line number Diff line number Diff line change
Expand Up @@ -584,11 +584,10 @@ uis.controller('uiSelectCtrl',
}
break;
case KEY.UP:
var minActiveIndex = (ctrl.search.length === 0 && ctrl.tagging.isActivated) ? -1 : 0;
if (!ctrl.open && ctrl.multiple) ctrl.activate(false, true); //In case its the search input in 'multiple' mode
else if (ctrl.activeIndex > minActiveIndex) {
else if (ctrl.activeIndex > 0) {
var idxmin = --ctrl.activeIndex;
while(_isItemDisabled(ctrl.items[idxmin]) && idxmin > minActiveIndex) {
while(_isItemDisabled(ctrl.items[idxmin]) && idxmin > 0) {
ctrl.activeIndex = --idxmin;
}
}
Expand Down
6 changes: 3 additions & 3 deletions test/select.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2971,7 +2971,7 @@ describe('ui-select tests', function () {
triggerKeydown(searchInput, Key.Down);
expect(el.scope().$select.activeIndex).toBe(2);
triggerKeydown(searchInput, Key.Up);
expect(el.scope().$select.activeIndex).toBe(-1);
expect(el.scope().$select.activeIndex).toBe(0);
});

it('should ignored disabled items going down', function () {
Expand All @@ -2992,7 +2992,7 @@ describe('ui-select tests', function () {
triggerKeydown(searchInput, Key.Down);
expect(el.scope().$select.activeIndex).toBe(2);
triggerKeydown(searchInput, Key.Up);
expect(el.scope().$select.activeIndex).toBe(-1);
expect(el.scope().$select.activeIndex).toBe(0);
});

it('should ignore disabled items, going down with remove-selected on false', function () {
Expand Down Expand Up @@ -3548,7 +3548,7 @@ describe('ui-select tests', function () {
triggerKeydown(searchInput, Key.Down);
expect(el.scope().$select.activeIndex).toBe(2);
triggerKeydown(searchInput, Key.Up);
expect(el.scope().$select.activeIndex).toBe(-1);
expect(el.scope().$select.activeIndex).toBe(0);
});

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

0 comments on commit d8fed30

Please sign in to comment.