From 6c6999d5f15cfbd2d8f24a4f19196d5fd0525a14 Mon Sep 17 00:00:00 2001 From: Dominik Reh Date: Sun, 30 Oct 2022 16:10:55 +0100 Subject: [PATCH] Fix diff check for negative tag count changes Now properly closes the popup if the last letter of a tag gets deleted. --- javascript/tagAutocomplete.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/javascript/tagAutocomplete.js b/javascript/tagAutocomplete.js index 2d8f18b..642fc8a 100644 --- a/javascript/tagAutocomplete.js +++ b/javascript/tagAutocomplete.js @@ -407,10 +407,13 @@ async function autocomplete(textArea, prompt, fixedTag = null) { tags = tags.filter(tag => !weightedTags.some(weighted => tag.includes(weighted))) .concat(weightedTags); } + + let tagCountChange = tags.length - previousTags.length; + let diff = difference(tags, previousTags); previousTags = tags; - // Guard for no difference / only whitespace remaining - if (diff === null || diff.length === 0) { + // Guard for no difference / only whitespace remaining / last edited tag was fully removed + if (diff === null || diff.length === 0 || (diff.length === 1 && tagCountChange < 0)) { if (!hideBlocked) hideResults(textArea); return; }