Igor Vaynberg 13 năm trước cách đây
mục cha
commit
5a73385474
1 tập tin đã thay đổi với 6 bổ sung1 xóa
  1. 6 1
      select2.js

+ 6 - 1
select2.js

@@ -488,11 +488,16 @@
                     this.highlightUnderEvent(e);
                     this.highlightUnderEvent(e);
                     this.selectHighlighted(e);
                     this.selectHighlighted(e);
                 } else {
                 } else {
-                    killEvent(e);
                     this.focusSearch();
                     this.focusSearch();
                 }
                 }
+                killEvent(e);
             }));
             }));
 
 
+            // trap all mouse events from leaving the dropdown. sometimes there may be a modal that is listening
+            // for mouse events outside of itself so it can close itself. since the dropdown is now outside the select2's
+            // dom it will trigger the popup close, which is not what we want
+            this.dropdown.bind("click mouseup mousedown", function (e) { e.stopPropagation(); });
+
             if ($.isFunction(this.opts.initSelection)) {
             if ($.isFunction(this.opts.initSelection)) {
                 // initialize selection based on the current value of the source element
                 // initialize selection based on the current value of the source element
                 this.initSelection();
                 this.initSelection();