Browse Source

Dont trigger searches when the field is empty, and allow escaping it by pressing arrows

Jordi Boggiano 12 years ago
parent
commit
d5b8ccffd5
1 changed files with 6 additions and 1 deletions
  1. 6 1
      src/Packagist/WebBundle/Resources/public/js/search.js

+ 6 - 1
src/Packagist/WebBundle/Resources/public/js/search.js

@@ -32,7 +32,7 @@
             return;
         }
 
-        if (form.find('input').val() === "") {
+        if ($('#search_query_query').val().match(/^\s*$/) !== null) {
             list.addClass('hidden');
             return;
         }
@@ -80,6 +80,11 @@
             return;
         }
 
+        if ($('#search_query_query').val().match(/^\s*$/) !== null) {
+            document.activeElement.blur();
+            return;
+        }
+
         event.preventDefault();
 
         currentSelected = list.find('ul.packages li.selected');