Browse Source

HUE-2237 [search] Search input duplicates text

Removed funky input box behavior
Enrico Berti 11 năm trước cách đây
mục cha
commit
f306348050
1 tập tin đã thay đổi với 19 bổ sung11 xóa
  1. 19 11
      desktop/core/static/js/ko.hue-bindings.js

+ 19 - 11
desktop/core/static/js/ko.hue-bindings.js

@@ -553,17 +553,25 @@ ko.bindingHandlers.clearable = {
     }
 
     _el.addClass("clearable");
-    _el.on("input", function () {
-      _el[tog(this.value)]("x");
-      valueAccessor()(_el.val());
-    }).on("mousemove", function (e) {
-      _el[tog(this.offsetWidth - 18 < e.clientX - this.getBoundingClientRect().left)]("onX");
-    }).on("click", function (e) {
-      if (this.offsetWidth - 18 < e.clientX - this.getBoundingClientRect().left) {
-        _el.removeClass("x onX").val("");
-        valueAccessor()("");
-      }
-    });
+    _el
+      .on("input", function () {
+        _el[tog(this.value)]("x");
+      })
+      .on("change", function () {
+        valueAccessor()(_el.val());
+      })
+      .on("blur", function () {
+        valueAccessor()(_el.val());
+      })
+      .on("mousemove", function (e) {
+        _el[tog(this.offsetWidth - 18 < e.clientX - this.getBoundingClientRect().left)]("onX");
+      })
+      .on("click", function (e) {
+        if (this.offsetWidth - 18 < e.clientX - this.getBoundingClientRect().left) {
+          _el.removeClass("x onX").val("");
+          valueAccessor()("");
+        }
+      });
   },
   update: function (element, valueAccessor, allBindingsAccessor) {
     $(element).val(ko.unwrap(valueAccessor()));