Browse Source

Fix autocomplete chip X "ends with" conflicts

Clicking the X button in an autocomplete chip could inadvertently remove
the wrong tag (and cause a weird "merging" behavior) if another tag
ended with the same text as the one being removed. For example, if a
post had both "one.two" and "two" tags and you clicked the X button on
the "two".
merge-requests/110/head
Deimos 5 years ago
parent
commit
83ce08248d
  1. 2
      tildes/static/js/behaviors/autocomplete-chip-clear.js

2
tildes/static/js/behaviors/autocomplete-chip-clear.js

@ -6,7 +6,7 @@ $.onmount("[data-js-autocomplete-chip-clear]", function() {
var $tagsHiddenInput = $("[data-js-autocomplete-hidden-input]");
var $autocompleteInput = $("[data-js-autocomplete-input]");
var textToReplace = new RegExp($chip.text() + ",");
var textToReplace = new RegExp("(^|,)" + $chip.text() + ",");
$tagsHiddenInput.val($tagsHiddenInput.val().replace(textToReplace, ""));
$chip.remove();
$autocompleteInput.focus();

Loading…
Cancel
Save