title: JQuery UI Dialog not closing when launched from Input focus event
body: <p>I have a problem using JQuery and JQuery UI. I have moved to the latest stable version in case that was the issue but I have determined that it isn't.
  I am using Chrome</p>
  
  <p>When I use the dialog I created by clicking the  element it works without a problem. You can open it and close it mutiple times.</p>
  
  <p>When I use the dialog by clicking the input box (I use the focus event). It opens but it will never close. It dissapears from the screen but the screen remains in modal. If I call the dialog isOpen function I still get true.</p>
  
  <p>I can't find any documentation on this. Can anyone explain the difference in behaviour?</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;html&gt;
  &lt;head&gt;
  &lt;link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.0/jquery-ui.min.css"&gt;
  &lt;script src="https://code.jquery.com/jquery-3.1.0.min.js"&gt;&lt;/script&gt;
  &lt;script src="https://code.jquery.com/ui/1.12.0/jquery-ui.min.js"&gt;&lt;/script&gt;
  
  &lt;script&gt;
  
   function RepetitionIntervalInput_display(str, title, okfn, cancelfn) {
   
    $( "#RepetitionIntervalInput_dlg" ).dialog( "open" );
   };
   $(document).ready(function() {
  
    var ret = "&lt;div id=\"RepetitionIntervalInput_dlg\" title=\"Input Repetition Interval\"&gt;";
  
    ret += "&lt;/div&gt;";
    $("body").append(ret);
    $( "#RepetitionIntervalInput_dlg" ).dialog({
     autoOpen: false,
     width: 500,
     modal: true
    });
  
  
    $(document).on('click.tab_stateset', "a[href$='#tab_stateset_delete']", function(event) {
     RepetitionIntervalInput_display(
      "STRING", 
      "TITLE", 
      function () {
       console.log("OK");
      }, 
      function () {
       console.log("CANC");
      }
     );
     event.preventDefault();      
    });
  
    $(document).on('focus.tab_stateedit', ".tab_stateedit_repetitioninterval", function() {
     RepetitionIntervalInput_display(
      "STRING", 
      "TITLE", 
      function () {
       console.log("OK");
      }, 
      function () {
       console.log("CANC");
      }
     );
    });
  
   });
  &lt;/script&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
  &lt;h1&gt;A&lt;/h1&gt;
  &lt;a href="#tab_stateset_delete"&gt;aaa&lt;/a&gt;
  &lt;input type="text" value="NULL" class="tab_stateedit_repetitioninterval"&gt;&lt;/input&gt;
  &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>