Fix adding empty tag on focus out from element
For some reason, i was looking at the value of the focus’ **target**, which is not my search field at all, but whatever control the focus changes **to**. It that new control is an input with value, then it created a new tag with whatever my search field had, which could be the empty string.
This commit is contained in:
parent
33277454fa
commit
3b568b013f
|
@ -73,7 +73,7 @@ class Multiselect extends HTMLDivElement {
|
||||||
}
|
}
|
||||||
window.addEventListener('focusin', this.onFocusOutHandler);
|
window.addEventListener('focusin', this.onFocusOutHandler);
|
||||||
document.addEventListener('click', this.onFocusOutHandler);
|
document.addEventListener('click', this.onFocusOutHandler);
|
||||||
|
|
||||||
this.rebuild()
|
this.rebuild()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -345,7 +345,7 @@ class Tags extends HTMLDivElement {
|
||||||
this.search.addEventListener('keydown', this.onSearchKeydownHandler);
|
this.search.addEventListener('keydown', this.onSearchKeydownHandler);
|
||||||
this.onFocusOutHandler = (e) => {
|
this.onFocusOutHandler = (e) => {
|
||||||
if (this.contains(e.target)) return;
|
if (this.contains(e.target)) return;
|
||||||
if (e.target.value && e.target.value.trim() !== '') {
|
if (this.search.value && this.search.value.trim() !== '') {
|
||||||
this.createTag();
|
this.createTag();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue