Skip to content

Commit

Permalink
fix(dropdown): fix select always showing remove icon
Browse files Browse the repository at this point in the history
Closes #271
  • Loading branch information
lubber-de authored and Sean committed Dec 18, 2018
1 parent 6865e08 commit 024b7d6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/definitions/modules/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -2146,6 +2146,11 @@ $.fn.dropdown = function(parameters) {
else {
module.set.selected();
}
if(module.get.item()) {
$input.removeClass(className.noselection);
} else {
$input.addClass(className.noselection);
}
module.remove.initialLoad();
},
remoteValues: function() {
Expand Down Expand Up @@ -2514,6 +2519,11 @@ $.fn.dropdown = function(parameters) {
$element.addClass(className.leftward);
},
value: function(value, text, $selected) {
if(value !== undefined && value !== '' && !(Array.isArray(value) && value.length === 0)) {
$input.removeClass(className.noselection);
} else {
$input.addClass(className.noselection);
}
var
escapedValue = module.escape.value(value),
hasInput = ($input.length > 0),
Expand Down Expand Up @@ -3945,7 +3955,8 @@ $.fn.dropdown.settings = {
upward : 'upward',
leftward : 'left',
visible : 'visible',
clearable : 'clearable'
clearable : 'clearable',
noselection : 'noselection'
}

};
Expand Down
2 changes: 2 additions & 0 deletions src/definitions/modules/dropdown.less
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,7 @@ select.ui.dropdown {

/* Clearable Selection */
.ui.dropdown .remove.icon {
cursor: pointer;
font-size: @dropdownIconSize;
margin: @selectionIconMargin;
padding: @selectionIconPadding;
Expand All @@ -647,6 +648,7 @@ select.ui.dropdown {
margin-right: 1.5em;
}

.ui.dropdown select.noselection ~ .remove.icon,
.ui.dropdown input[value=''] ~ .remove.icon,
.ui.dropdown input:not([value]) ~ .remove.icon,
.ui.dropdown.loading .remove.icon {
Expand Down

0 comments on commit 024b7d6

Please sign in to comment.