Problem was that when the user types quickly in the search bar and press
enter, the keydown event of the enter key happens before the keypress
event of the last key entered. This means that the autocompletion has
a wrong string. The fix is to move the enter selection detection from
keydown to keyup.
ev.preventDefault();
return;
}
+ if (ev.which === $.ui.keyCode.ENTER) {
+ if (self.current_result && self.get_search_string().length) {
+ self.select_item(ev);
+ }
+ return;
+ }
if (!self.searching) {
self.searching = true;
return;
this.$input.on('keydown', function (ev) {
switch (ev.which) {
case $.ui.keyCode.TAB:
- case $.ui.keyCode.ENTER:
if (self.current_result && self.get_search_string().length) {
self.select_item(ev);
}