From 5d3794f08ce98475e1c857246084da6a29ae1868 Mon Sep 17 00:00:00 2001 From: Bauke Date: Sun, 28 Jul 2019 10:36:06 +0200 Subject: [PATCH] Fix tag autocomplete comparison to existing tags --- tildes/static/js/behaviors/autocomplete-menu-item.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tildes/static/js/behaviors/autocomplete-menu-item.js b/tildes/static/js/behaviors/autocomplete-menu-item.js index 57a901b..9a93874 100644 --- a/tildes/static/js/behaviors/autocomplete-menu-item.js +++ b/tildes/static/js/behaviors/autocomplete-menu-item.js @@ -11,7 +11,12 @@ $.onmount("[data-js-autocomplete-menu-item]", function() { var $tagsHiddenInput = $("[data-js-autocomplete-hidden-input]"); var $autocompleteInput = $("[data-js-autocomplete-input]"); - if (!$tagsHiddenInput.val().includes(clickedSuggestionText + ",")) { + var existingTags = $tagsHiddenInput.val().split(","); + if ( + existingTags.every(function(val) { + return val !== clickedSuggestionText; + }) + ) { var $chips = $autocompleteContainer .find("[data-js-autocomplete-chips]") .first();