diff --git a/javascript/tagAutocomplete.js b/javascript/tagAutocomplete.js index b7c866f..dd63fcd 100644 --- a/javascript/tagAutocomplete.js +++ b/javascript/tagAutocomplete.js @@ -576,6 +576,8 @@ async function autocomplete(textArea, prompt, fixedTag = null) { // Guard for empty prompt if (prompt.length === 0) { hideResults(textArea); + previousTags = []; + tagword = ""; return; } @@ -590,6 +592,14 @@ async function autocomplete(textArea, prompt, fixedTag = null) { .concat(weightedTags); } + // Guard for no tags + if (!tags || tags.length === 0) { + previousTags = []; + tagword = ""; + hideResults(textArea); + return; + } + let tagCountChange = tags.length - previousTags.length; let diff = difference(tags, previousTags); previousTags = tags;