title: Primefaces dialog keeps focus after being hidden
body: <p>H1 everyone ! Let the following scenario in JSF 2.0 (Mojarra 2.2, Glassfish 4, <strong>Primefaces 4.0</strong>) :</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="fr"
      xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"&gt;
      &lt;h:head&gt;
          &lt;title&gt;Title&lt;/title&gt;
      &lt;/h:head&gt;
      &lt;h:body onload="PF('dlg').show()"&gt;
          &lt;p:dialog widgetVar="dlg"
              resizable="false" closable="false" &gt;
              &lt;h:form id="form"&gt;
                  &lt;h:outputLabel for="name" value="Name:" /&gt; 
                  &lt;p:inputText id="name" /&gt;
                  &lt;p:commandButton id="submitButton" value="Submit" /&gt;
                  &lt;p:commandButton id="cancelButton" value="Cancel"
                      onclick="alert('ok'); PF('dlg').hide();" /&gt;
              &lt;/h:form&gt;
          &lt;/p:dialog&gt;
      &lt;/h:body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>The issue is that the Primefaces dialog keeps focus after being hidden : when pressing spacebar or enter key after having canceled the dialog, you can observe that the alert 'ok' will be displayed again!</p>
  
  <p>When trying to set focus out of the dialog using : <code>onclick="alert('ok'); PF('dlg').hide(); PF('dlg').blur()"</code> or <code>onclick="alert('ok'); PF('dlg').hide(); PF('dlg').focusout()"</code>, it seems that the whole body is reloaded since the dialog reappears...</p>
  
  <p>Am I doing something wrong ? Is it a misconception of mine or a bug in Primefaces ?
  Any help will be gratefully appreciated :)</p>