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

Select first option no mater if it creates new tag or offers existing… #1915

Merged
merged 2 commits into from
Mar 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/uiSelectController.js
Original file line number Diff line number Diff line change
Expand Up @@ -569,11 +569,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 @@ -2813,7 +2813,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 @@ -2834,7 +2834,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 @@ -3238,7 +3238,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