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

Commit 9d11dd1

Browse files
Jefiozieuser378230
authored andcommitted
fix(isDisabled) Item not re-enabled when no longer disabled
Causes issue where items could not be re-selected when using remove-selected=true as the item could not be re-enabled once it was deselected. Closes #1739
1 parent b15189d commit 9d11dd1

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/uiSelectController.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ uis.controller('uiSelectCtrl',
333333
}
334334

335335
if (!isDisabled && disabledItemIndex > -1) {
336-
disabledItems.splice(disabledItemIndex, 0);
336+
disabledItems.splice(disabledItemIndex, 1);
337337
}
338338
}
339339

test/select.spec.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1809,6 +1809,7 @@ describe('ui-select tests', function() {
18091809
if (attrs.inputId !== undefined) { attrsHtml += ' input-id="' + attrs.inputId + '"'; }
18101810
if (attrs.groupBy !== undefined) { choicesAttrsHtml += ' group-by="' + attrs.groupBy + '"'; }
18111811
if (attrs.lockChoice !== undefined) { matchesAttrsHtml += ' ui-lock-choice="' + attrs.lockChoice + '"'; }
1812+
if (attrs.removeSelected !== undefined) { attrsHtml += ' remove-selected="' + attrs.removeSelected + '"'; }
18121813
}
18131814

18141815
return compileTemplate(
@@ -2743,6 +2744,16 @@ describe('ui-select tests', function() {
27432744
clickItem(el, 'Samantha');
27442745
expect(el.hasClass('ng-not-empty')).toBeTruthy();
27452746
});
2747+
2748+
it('should be able to re-select the item with removeselected set to false', function() {
2749+
scope.selection.selectedMultiple = [scope.people[4], scope.people[5]]; //Wladimir & Samantha
2750+
var el = createUiSelectMultiple({removeSelected : true});
2751+
expect(el.scope().$select.selected.length).toBe(2);
2752+
el.find('.ui-select-match-item').first().find('.ui-select-match-close').click();
2753+
expect(el.scope().$select.selected.length).toBe(1);
2754+
clickItem(el, 'Wladimir');
2755+
expect(el.scope().$select.selected.length).toBe(2);
2756+
});
27462757
});
27472758

27482759
it('should add an id to the search input field', function () {

0 commit comments

Comments
 (0)