-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat(removeSelected): Implement removeSelected property for multiple selects #1622
Conversation
…selects Implement remove-selected="false" for multiple selects. This will disable a choice in the dropdown of a multiple-select element instead of removing it.
@@ -325,9 +330,9 @@ uis.controller('uiSelectCtrl', | |||
var isDisabled = false; | |||
var item; | |||
|
|||
if (itemIndex >= 0 && !angular.isUndefined(ctrl.disableChoiceExpression)) { | |||
if (itemIndex >= 0 && (!angular.isUndefined(ctrl.disableChoiceExpression) || ctrl.multiple)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dondi could you add an extra set of brackets here just to make the condition precedence clear?
Eg.
if (itemIndex >= 0 && ((!angular.isUndefined(ctrl.disableChoiceExpression) || ctrl.multiple)))
Or..?
if ((itemIndex >= 0 && (!angular.isUndefined(ctrl.disableChoiceExpression)) || ctrl.multiple))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually the parentheses already disambiguate the precedence. The current code is shown below, with the matching middle parentheses spaced out for emphasis:
if (itemIndex >= 0 && ( !angular.isUndefined(ctrl.disableChoiceExpression) || ctrl.multiple ) ) {
Those parentheses ensure that the ||
in the middle takes precedence. The suggestions made above would result in double-parentheses on the same expression (the disjunction in the first example; the entire condition in the second example).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I totally misread it, my bad! 😳
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries, all good—thanks for reviewing!
Great, thanks! I've added a section on this to the wiki. I made it an example section instead of adding it to the attribute table because it really only applies for |
@user378230 Is there any indication on when this feature will be released? |
Expose and implement
remove-selected="false"
for multiple selects. This will disable a choicein the dropdown of a multiple-select element instead of removing it.
Sample behavior:

In the existing version,
id
would not have appeared in the dropdown because it is currently selected. This pull request adds the optionremoveSelected
so that, if set tofalse
, selected items still appear in the dropdown but are disabled (like in the screenshot).