From 34fb3f69103801362e4937f8d32106a0c63b59f4 Mon Sep 17 00:00:00 2001 From: Yader Velasquez Date: Fri, 9 Feb 2024 15:30:43 -0600 Subject: [PATCH] Fix autocomplete. Avoid displaying empty suggestion block --- static/js/autocomplete.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/static/js/autocomplete.js b/static/js/autocomplete.js index dd7f539..0bfc575 100644 --- a/static/js/autocomplete.js +++ b/static/js/autocomplete.js @@ -15,12 +15,14 @@ tagSelector.addEventListener("keyup", function(event) { return response.json(); }) .then(function (data) { - var t = ""; - for (var i=0; i < data.length; i++) { - t += '

' + data[i].Name + '

'; + if (data.length > 0) { + var t = ""; + for (var i=0; i < data.length; i++) { + t += '

' + data[i].Name + '

'; + } + autocompleteTags.innerHTML = t; + autocompleteTags.classList.remove("d-none"); } - autocompleteTags.innerHTML = t; - autocompleteTags.classList.remove("d-none"); }) .catch(function (error) { console.log("Fetch error:", error); -- 2.45.2