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 6 years ago
parent
commit
11bd40d04b
  1. 2
      tildes/static/js/behaviors/autocomplete-input.js

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

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

Loading…
Cancel
Save