From 0eea654a48b35de2f7bfa6067a9160ea40237082 Mon Sep 17 00:00:00 2001 From: evazion Date: Thu, 25 Feb 2021 15:09:35 -0600 Subject: [PATCH] autocomplete: fix empty autocomplete calls when toggling related tags. This happens because toggling a related tag updates the tag box, which triggers autocomplete, which can't find a tag because the cursor isn't in the tag box, so it ends up making an autocomplete call for the empty string. --- app/javascript/src/javascripts/autocomplete.js.erb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/javascript/src/javascripts/autocomplete.js.erb b/app/javascript/src/javascripts/autocomplete.js.erb index 7f94c924d..3205b52a8 100644 --- a/app/javascript/src/javascripts/autocomplete.js.erb +++ b/app/javascript/src/javascripts/autocomplete.js.erb @@ -199,6 +199,10 @@ Autocomplete.render_item = function(list, item) { }; Autocomplete.autocomplete_source = function(query, type) { + if (query === "") { + return []; + } + return $.getJSON("/autocomplete.json", { "search[query]": query, "search[type]": type,