mirror of
https://github.com/Choices-js/Choices.git
synced 2024-06-16 04:35:03 +02:00
Fix adding choices when duplicateItems is false
This commit is contained in:
parent
940f695a1c
commit
9af97cad51
|
@ -1389,8 +1389,18 @@ class Choices {
|
||||||
|
|
||||||
if (this.isTextElement) {
|
if (this.isTextElement) {
|
||||||
this._addItem(value);
|
this._addItem(value);
|
||||||
} else if(this.config.addItems) {
|
} else {
|
||||||
this._addChoice(true, false, value, value);
|
let isUnique;
|
||||||
|
if (!duplicateItems) {
|
||||||
|
isUnique = !this.store
|
||||||
|
.getItems()
|
||||||
|
.some((item) => item.value === value.trim());
|
||||||
|
}
|
||||||
|
if (duplicateItems || isUnique) {
|
||||||
|
this._addChoice(true, false, value, value);
|
||||||
|
} else {
|
||||||
|
this._addItem(value);
|
||||||
|
}
|
||||||
this.containerOuter.focus();
|
this.containerOuter.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue