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();