[fix] do not autocomplete for pressing enter when mouse is on the completion list - fixes #340

This commit is contained in:
Adam Tauber 2020-06-03 15:36:22 +02:00
parent 47cddcab8b
commit 08fdfc73fb
3 changed files with 20 additions and 2 deletions

View file

@ -78,7 +78,13 @@ if(searx.autocompleter) {
}
$(document).ready(function(){
var original_search_value = '';
if(searx.autocompleter) {
$("#q").on('keydown', function(e) {
if(e.which == 13) {
original_search_value = $('#q').val();
}
});
$('#q').typeahead(null, {
name: 'search-results',
displayKey: function(result) {
@ -87,6 +93,9 @@ $(document).ready(function(){
source: searx.searchResults.ttAdapter()
});
$('#q').bind('typeahead:selected', function(ev, suggestion) {
if(original_search_value) {
$('#q').val(original_search_value);
}
$("#search_form").submit();
});
}

File diff suppressed because one or more lines are too long

View file

@ -25,7 +25,13 @@ if(searx.autocompleter) {
}
$(document).ready(function(){
var original_search_value = '';
if(searx.autocompleter) {
$("#q").on('keydown', function(e) {
if(e.which == 13) {
original_search_value = $('#q').val();
}
});
$('#q').typeahead(null, {
name: 'search-results',
displayKey: function(result) {
@ -34,6 +40,9 @@ $(document).ready(function(){
source: searx.searchResults.ttAdapter()
});
$('#q').bind('typeahead:selected', function(ev, suggestion) {
if(original_search_value) {
$('#q').val(original_search_value);
}
$("#search_form").submit();
});
}