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; : null;
}, },
parseHook: input => parseHook: input =>
input.map(inputValue => { input.map(inputValue => EmailModel.parseEmailLine(inputValue))
const values = EmailModel.parseEmailLine(inputValue); .flat(Infinity)
return values.length ? values : inputValue; .map(item => (item.toLine ? [item.toLine(false), item] : [item, null])),
}).flat(Infinity).map(
item => (item.toLine ? [item.toLine(false), item] : [item, null])
),
onChange: value => { onChange: value => {
element.EmailsTagsValue = value; element.EmailsTagsValue = value;
fValue(value); fValue(value);

View file

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