Bugfix: inputosaurus failed due to changes

This commit is contained in:
djmaze 2021-02-03 12:55:49 +01:00
parent 88b0bc1a25
commit b0e3020aab
2 changed files with 10 additions and 10 deletions

View file

@ -77,12 +77,9 @@ ko.bindingHandlers.emailsTags = {
: null;
},
parseHook: input =>
input.map(inputValue => {
const values = EmailModel.parseEmailLine(inputValue);
return values.length ? values : inputValue;
}).flat(Infinity).map(
item => (item.toLine ? [item.toLine(false), item] : [item, null])
),
input.map(inputValue => EmailModel.parseEmailLine(inputValue))
.flat(Infinity)
.map(item => (item.toLine ? [item.toLine(false), item] : [item, null])),
onChange: value => {
element.EmailsTagsValue = value;
fValue(value);

View file

@ -80,7 +80,7 @@ this.Inputosaurus = class {
self.input.addEventListener('focus', () => self._focusTrigger(true));
self.input.addEventListener('blur', () => {
// prevent autoComplete menu click from causing a false 'blur'
self._parseInput();
self._parseInput(true);
self._focusTrigger(false);
});
self.input.addEventListener('keydown', e => {
@ -97,7 +97,7 @@ this.Inputosaurus = class {
self._updateDatalist();
} else if (e.key == 'Enter') {
e.preventDefault();
self._parseInput();
self._parseInput(true);
}
});
self.input.addEventListener('input', () => {
@ -148,8 +148,11 @@ this.Inputosaurus = class {
datalist.textContent = '';
}
_parseInput() {
this._parseValue(this.input.value) && (this.input.value = '');
_parseInput(force) {
let val = this.input.value;
if (force || val.includes(',') || val.includes(';')) {
this._parseValue(val) && (this.input.value = '');
}
this._resizeInput();
}