mirror of
https://github.com/Choices-js/Choices.git
synced 2024-06-08 08:52:19 +02:00
Refactoring
This commit is contained in:
parent
9b6cc40f58
commit
5f0545d604
4
assets/scripts/dist/choices.min.js
vendored
4
assets/scripts/dist/choices.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -760,23 +760,17 @@ export default class Choices {
|
||||||
const choice = this.store.getChoiceById(id);
|
const choice = this.store.getChoiceById(id);
|
||||||
|
|
||||||
if (choice && !choice.selected && !choice.disabled) {
|
if (choice && !choice.selected && !choice.disabled) {
|
||||||
let canAddItem = true;
|
const canAddItem = this._canAddItem(activeItems, choice.value);
|
||||||
|
|
||||||
if (this.config.maxItemCount > 0 && this.config.maxItemCount <= activeItems.length && this.passedElement.type === 'select-multiple') {
|
if (canAddItem.response) {
|
||||||
canAddItem = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (canAddItem) {
|
|
||||||
this._addItem(choice.value, choice.label, choice.id);
|
this._addItem(choice.value, choice.label, choice.id);
|
||||||
this._triggerChange(choice.value);
|
this._triggerChange(choice.value);
|
||||||
|
this.clearInput(this.passedElement);
|
||||||
|
this.isSearching = false;
|
||||||
|
this.store.dispatch(activateChoices(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.passedElement.type === 'select-one') {
|
if (this.passedElement.type === 'select-one') {
|
||||||
if (this.canSearch) {
|
|
||||||
this.input.value = '';
|
|
||||||
}
|
|
||||||
this.isSearching = false;
|
|
||||||
this.store.dispatch(activateChoices(true));
|
|
||||||
this.hideDropdown();
|
this.hideDropdown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue