Skip to content

Commit 34abb0e

Browse files
authored
fix(dropdown): encoded select values, multiple maxselections
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
1 parent db3ee2f commit 34abb0e

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/definitions/modules/dropdown.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@
529529
callback = isFunction(callback)
530530
? callback
531531
: function () {};
532-
if ((focused || iconClicked) && module.is.remote() && module.is.noApiCache()) {
532+
if ((focused || iconClicked) && module.is.remote() && module.is.noApiCache() && !module.has.maxSelections()) {
533533
module.clearItems();
534534
}
535535
if (!module.can.show() && module.is.remote()) {
@@ -774,6 +774,8 @@
774774
}
775775
;
776776
if (settings.useLabels && module.has.maxSelections()) {
777+
module.show();
778+
777779
return;
778780
}
779781
if (settings.apiSettings) {
@@ -2170,7 +2172,7 @@
21702172
return;
21712173
}
21722174
if (isMultiple) {
2173-
if ($.inArray(module.escape.htmlEntities(String(optionValue)), value.map(String)) !== -1) {
2175+
if ($.inArray(module.escape.htmlEntities(String(optionValue)), value.map(String).map(module.escape.htmlEntities)) !== -1) {
21742176
$selectedItem = $selectedItem
21752177
? $selectedItem.add($choice)
21762178
: $choice;
@@ -2231,7 +2233,7 @@
22312233
return false;
22322234
}
22332235

2234-
return true;
2236+
return false;
22352237
},
22362238
disabled: function () {
22372239
$search.attr('tabindex', module.is.disabled() ? -1 : 0);
@@ -2321,7 +2323,7 @@
23212323
$.each(values, function (value, name) {
23222324
module.set.text(name);
23232325
});
2324-
} else {
2326+
} else if (settings.useLabels) {
23252327
$.each(values, function (value, name) {
23262328
module.add.label(value, name);
23272329
});

0 commit comments

Comments
 (0)