فهرست منبع

HUE-5921 [assist] Don’t show the assist search autocomplete after pressing return

Johan Ahlen 8 سال پیش
والد
کامیت
7e2bb5f
1فایلهای تغییر یافته به همراه13 افزوده شده و 1 حذف شده
  1. 13 1
      desktop/core/src/desktop/static/desktop/js/ko.hue-bindings.js

+ 13 - 1
desktop/core/src/desktop/static/desktop/js/ko.hue-bindings.js

@@ -84,6 +84,8 @@
       var options = valueAccessor();
       var $element = $(element);
 
+      var delay = 400;
+
       options = $.extend({
         addCount: false,
         closeOnEnter: true,
@@ -94,7 +96,7 @@
         limitWidthToInput: false,
         minWidth: 200,
         disabled: true,
-        delay: 400
+        delay: delay
       }, options);
 
       if (options.addCount) {
@@ -186,6 +188,16 @@
         } else if (e.which === 32 && e.ctrlKey) {
           $element.hueAutocomplete('search', $element.val());
         }
+        if (e.which === 13) {
+          // Prevent autocomplete on enter
+          $element.hueAutocomplete('close');
+          $element.hueAutocomplete("option", "disabled", true);
+          window.setTimeout(function () {
+            $element.hueAutocomplete("option", "disabled", false);
+          }, delay + 100);
+          e.preventDefault();
+          return false;
+        }
       });
 
       if (options.showOnFocus) {