Browse Source

Fix empty tag field behavior when backspacing

If there were no tag chips, backspacing on the empty field would lose
focus (and on some browsers, another backspace would then go back).
merge-requests/68/head
Deimos 5 years ago
parent
commit
11bd40d04b
  1. 10
      tildes/static/js/behaviors/autocomplete-input.js

10
tildes/static/js/behaviors/autocomplete-input.js

@ -105,10 +105,12 @@ $.onmount('[data-js-autocomplete-input]', function() {
var $tagsHiddenInput = $("[data-js-autocomplete-hidden-input]");
var $lastChip = $chips.children().last();
$(this).blur();
if (!$lastChip.hasClass('active')) {
$lastChip.addClass("active");
$lastChip.children('[data-js-autocomplete-chip-clear]').first().focus();
if ($lastChip.length) {
$(this).blur();
if (!$lastChip.hasClass('active')) {
$lastChip.addClass("active");
$lastChip.children('[data-js-autocomplete-chip-clear]').first().focus();
}
}
}
break;

Loading…
Cancel
Save