Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions ui/jquery.ui.dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ $.widget( "ui.dialog", {
enable: $.noop,

close: function( event ) {
var that = this;
var activeElement,
that = this;

if ( !this._isOpen || this._trigger( "beforeClose", event ) === false ) {
return;
Expand All @@ -179,10 +180,22 @@ $.widget( "ui.dialog", {
this._destroyOverlay();

if ( !this.opener.filter(":focusable").focus().length ) {
// Hiding a focused element doesn't trigger blur in WebKit
// so in case we have nothing to focus on, explicitly blur the active element
// https://bugs.webkit.org/show_bug.cgi?id=47182
$( this.document[0].activeElement ).blur();

// support: IE9
// IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>
try {
activeElement = this.document[ 0 ].activeElement;

// Support: IE9, IE10
// If the <body> is blurred, IE will switch windows, see #4520
if ( activeElement && activeElement.nodeName.toLowerCase() !== "body" ) {

// Hiding a focused element doesn't trigger blur in WebKit
// so in case we have nothing to focus on, explicitly blur the active element
// https://bugs.webkit.org/show_bug.cgi?id=47182
$( activeElement ).blur();
}
} catch ( error ) {}
}

this._hide( this.uiDialog, this.options.hide, function() {
Expand Down