فهرست منبع

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

Jordi Boggiano 12 سال پیش
والد
کامیت
d5b8ccffd5
1فایلهای تغییر یافته به همراه6 افزوده شده و 1 حذف شده
  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');