mirror of
https://github.com/Choices-js/Choices.git
synced 2024-06-04 23:12:17 +02:00
Remove choice from choices list when duplicateItems is false
This commit is contained in:
parent
9af97cad51
commit
7a784270b2
|
@ -1392,14 +1392,14 @@ class Choices {
|
||||||
} else {
|
} else {
|
||||||
let isUnique;
|
let isUnique;
|
||||||
if (!duplicateItems) {
|
if (!duplicateItems) {
|
||||||
isUnique = !this.store
|
existingChoice = !this.store
|
||||||
.getItems()
|
.getItems()
|
||||||
.some((item) => item.value === value.trim());
|
.filter((item) => item.value === value.trim());
|
||||||
}
|
}
|
||||||
if (duplicateItems || isUnique) {
|
if (duplicateItems) {
|
||||||
this._addChoice(true, false, value, value);
|
this._addChoice(true, false, value, value);
|
||||||
} else {
|
} else {
|
||||||
this._addItem(value);
|
this._addItem(existingChoice.value, existingChoice.label, existingChoice.id);
|
||||||
}
|
}
|
||||||
this.containerOuter.focus();
|
this.containerOuter.focus();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue