Select2 in magnific popup: search input cannot be focused

I am using select2 jquery plugin along with a terrific popup. If I click on the select button in the popup that opens, a search window will appear with some results. The problem is that you don’t enter anything in the search field - the cursor simply does not appear. Here is a jsfiddle that demonstrates the problem http://jsfiddle.net/clime/qweWa/15/ . The code is as follows:

# html
<a href="#test-popup" class="open-popup-link">Show inline popup</a>

<div id="test-popup" class="white-popup mfp-hide">
    <select id="focus-blur-loop-select">
        <option>hello</option>
        <option>world</option>
    </select>
</div>

# js
$(function() {
  $('.open-popup-link').magnificPopup({
    type:'inline',
    midClick: true
  });

  $('#focus-blur-loop-select').select2({
      width: '200px'
  });
});

# css
.white-popup {
  position: relative;
  background: #FFF;
  padding: 20px;
  width: auto;
  max-width: 500px;
  margin: 20px auto;
}

I already did some basic research, and I found that the two callbacks below are called undefined. There seems to be some kind of infinite loop in the events.

// select2.js:742
search.on("focus", function () { search.addClass("select2-focused"); });
search.on("blur", function () { search.removeClass("select2-focused");});
+4
source share
2

: https://github.com/dimsemenov/Magnific-Popup/issues/280. , select2 . popup _onFocusIn:

$.magnificPopup.instance._onFocusIn = function(e) {
    // Do nothing if target element is select2 input
    if( $(e.target).hasClass('select2-input') ) {
       return true;
    } 
    // Else call parent method
    $.magnificPopup.proto._onFocusIn.call(this,e);
}
+5

"focus" magnificPopup:

$('.open-popup-link').magnificPopup({
  type:'inline',
  focus: '#focus-blur-loop-select',
  midClick: true
});

magnificPopup :

 ( )

CSS- , . , . , "enter" "# -". , .

+2
source

All Articles