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:
jordi fita mas 2023-04-11 10:23:32 +02:00
parent 33277454fa
commit 3b568b013f
1 changed files with 2 additions and 2 deletions

View File

@ -345,7 +345,7 @@ class Tags extends HTMLDivElement {
this.search.addEventListener('keydown', this.onSearchKeydownHandler);
this.onFocusOutHandler = (e) => {
if (this.contains(e.target)) return;
if (e.target.value && e.target.value.trim() !== '') {
if (this.search.value && this.search.value.trim() !== '') {
this.createTag();
}
};