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