Skip to content

Commit 35a4548

Browse files
authored
fix(dropdown): support manual removed entries
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.
1 parent 0a95751 commit 35a4548

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

src/definitions/modules/dropdown.js

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2798,19 +2798,27 @@
27982798
$selectedItem = settings.allowAdditions
27992799
? $selectedItem || module.get.itemWithAdditions(value)
28002800
: $selectedItem || module.get.item(value);
2801-
if (!$selectedItem) {
2801+
if (!$selectedItem && value !== undefined) {
28022802
return false;
28032803
}
2804-
module.debug('Setting selected menu item to', $selectedItem);
2805-
if (module.is.multiple() && !keepSearchTerm) {
2806-
module.remove.searchWidth();
2807-
}
2808-
if (module.is.single()) {
2804+
if (isMultiple) {
2805+
if (!keepSearchTerm) {
2806+
module.remove.searchWidth();
2807+
}
2808+
if (settings.useLabels) {
2809+
module.remove.selectedItem();
2810+
if (value === undefined) {
2811+
module.remove.labels($module.find(selector.label), true);
2812+
}
2813+
}
2814+
} else {
28092815
module.remove.activeItem();
28102816
module.remove.selectedItem();
2811-
} else if (settings.useLabels) {
2812-
module.remove.selectedItem();
28132817
}
2818+
if (!$selectedItem) {
2819+
return false;
2820+
}
2821+
module.debug('Setting selected menu item to', $selectedItem);
28142822
// select each item
28152823
$selectedItem
28162824
.each(function () {

0 commit comments

Comments
 (0)