Skip to content

Commit

Permalink
fix(dropdown): support manual removed entries
Browse files Browse the repository at this point in the history
When the input of a dropdown (which holds the selected values) was changed , the change does not recognize when values are missing, which have been selected before.
  • Loading branch information
lubber-de authored Feb 27, 2024
1 parent 0a95751 commit 35a4548
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/definitions/modules/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -2798,19 +2798,27 @@
$selectedItem = settings.allowAdditions
? $selectedItem || module.get.itemWithAdditions(value)
: $selectedItem || module.get.item(value);
if (!$selectedItem) {
if (!$selectedItem && value !== undefined) {
return false;
}
module.debug('Setting selected menu item to', $selectedItem);
if (module.is.multiple() && !keepSearchTerm) {
module.remove.searchWidth();
}
if (module.is.single()) {
if (isMultiple) {
if (!keepSearchTerm) {
module.remove.searchWidth();
}
if (settings.useLabels) {
module.remove.selectedItem();
if (value === undefined) {
module.remove.labels($module.find(selector.label), true);
}
}
} else {
module.remove.activeItem();
module.remove.selectedItem();
} else if (settings.useLabels) {
module.remove.selectedItem();
}
if (!$selectedItem) {
return false;
}
module.debug('Setting selected menu item to', $selectedItem);
// select each item
$selectedItem
.each(function () {
Expand Down

0 comments on commit 35a4548

Please sign in to comment.