title: jQuery UI Focus Stealing
body: <p>Whenever I type something in the following Insert Hyperlink text input, all the words are going to <code>textarea</code> behind it. OK and Cancel buttons are working fine but I cannot focus to text input.</p>
  
  <p>We'are using jQuery UI 1.10.1. It was working nicely with previous version of jQuery which was 1.8.x. </p>
  
  <p><img src="https://i.stack.imgur.com/BStcC.png" alt="enter image description here"></p>
  
  <p>I've checked code behind of jQuery and it has the following methods called when opening a Modal Dialog:</p>
  
  <pre><code>_focusTabbable: function () {
      // Set focus to the first match:
      // 1. First element inside the dialog matching [autofocus]
      // 2. Tabbable element inside the content element
      // 3. Tabbable element inside the buttonpane
      // 4. The close button
      // 5. The dialog itself
      var hasFocus = this.element.find("[autofocus]");
      if (!hasFocus.length) {
          hasFocus = this.element.find(":tabbable");
      }
      if (!hasFocus.length) {
          hasFocus = this.uiDialogButtonPane.find(":tabbable");
      }
      if (!hasFocus.length) {
          hasFocus = this.uiDialogTitlebarClose.filter(":tabbable");
      }
      if (!hasFocus.length) {
          hasFocus = this.uiDialog;
      }
      hasFocus.eq(0).focus();
  },
  
  _keepFocus: function (event) {
      function checkFocus() {
          var activeElement = this.document[0].activeElement,
              isActive = this.uiDialog[0] === activeElement ||
                  $.contains(this.uiDialog[0], activeElement);
          if (!isActive) {
              this._focusTabbable();
          }
      }
      event.preventDefault();
      checkFocus.call(this);
      // support: IE
      // IE &lt;= 8 doesn't prevent moving focus even with event.preventDefault()
      // so we check again later
      this._delay(checkFocus);
  },
  </code></pre>
  
  <p>that is taken from here: <a href="http://code.jquery.com/ui/1.10.1/jquery-ui.js" rel="noreferrer">http://code.jquery.com/ui/1.10.1/jquery-ui.js</a></p>