From 3b568b013fa1689c069d159d0b6a8fa693dc4499 Mon Sep 17 00:00:00 2001 From: jordi fita mas Date: Tue, 11 Apr 2023 10:23:32 +0200 Subject: [PATCH] Fix adding empty tag on focus out from element MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- web/static/numerus.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/static/numerus.js b/web/static/numerus.js index 9cf075f..21a84f6 100644 --- a/web/static/numerus.js +++ b/web/static/numerus.js @@ -73,7 +73,7 @@ class Multiselect extends HTMLDivElement { } window.addEventListener('focusin', this.onFocusOutHandler); document.addEventListener('click', this.onFocusOutHandler); - + this.rebuild() } } @@ -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(); } };