Skip to content

Commit

Permalink
fix(dropdown): encoded select values, multiple maxselections
Browse files Browse the repository at this point in the history
Some dropdown fixes:
a) multiple and maxselections allowed more than the limit to be selected when labels are used
b) uselabels:false + saveremotedata:true und preselected values created labels
c) init from select and preselected value including an ampersand wasn't preselected
  • Loading branch information
lubber-de authored May 17, 2023
1 parent db3ee2f commit 34abb0e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/definitions/modules/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@
callback = isFunction(callback)
? callback
: function () {};
if ((focused || iconClicked) && module.is.remote() && module.is.noApiCache()) {
if ((focused || iconClicked) && module.is.remote() && module.is.noApiCache() && !module.has.maxSelections()) {
module.clearItems();
}
if (!module.can.show() && module.is.remote()) {
Expand Down Expand Up @@ -774,6 +774,8 @@
}
;
if (settings.useLabels && module.has.maxSelections()) {
module.show();

return;
}
if (settings.apiSettings) {
Expand Down Expand Up @@ -2170,7 +2172,7 @@
return;
}
if (isMultiple) {
if ($.inArray(module.escape.htmlEntities(String(optionValue)), value.map(String)) !== -1) {
if ($.inArray(module.escape.htmlEntities(String(optionValue)), value.map(String).map(module.escape.htmlEntities)) !== -1) {
$selectedItem = $selectedItem
? $selectedItem.add($choice)
: $choice;
Expand Down Expand Up @@ -2231,7 +2233,7 @@
return false;
}

return true;
return false;
},
disabled: function () {
$search.attr('tabindex', module.is.disabled() ? -1 : 0);
Expand Down Expand Up @@ -2321,7 +2323,7 @@
$.each(values, function (value, name) {
module.set.text(name);
});
} else {
} else if (settings.useLabels) {
$.each(values, function (value, name) {
module.add.label(value, name);
});
Expand Down

0 comments on commit 34abb0e

Please sign in to comment.