Browse Source

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

Adam Tauber 4 years ago
parent
commit
08fdfc73fb

+ 9 - 0
searx/static/themes/oscar/js/searx.js

@@ -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 it is too large
+ 0 - 1
searx/static/themes/oscar/js/searx.min.js


+ 9 - 0
searx/static/themes/oscar/js/searx_src/autocompleter.js

@@ -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();
         });
     }

Some files were not shown because too many files changed in this diff