aboutsummaryrefslogtreecommitdiffstats
path: root/ui/jquery.ui.dialog.js
diff options
context:
space:
mode:
authorJörn Zaefferer <joern.zaefferer@gmail.com>2012-10-23 10:31:10 -0400
committerJörn Zaefferer <joern.zaefferer@gmail.com>2012-10-24 17:02:32 -0400
commit14691ae6feea2732ec5aeae57b4275aa0e4d1beb (patch)
treec98e38f2caef68070bb52975a472229f9e973002 /ui/jquery.ui.dialog.js
parent2a2a2c017c4395799ec07666f4ca14e078b52b5b (diff)
downloadjquery-ui-14691ae6feea2732ec5aeae57b4275aa0e4d1beb.tar.gz
jquery-ui-14691ae6feea2732ec5aeae57b4275aa0e4d1beb.zip
Dialog: Save the active element that opened the dialog and restore focus to that. Fixes #8730 - Dialog: Restore focus to opener.
Diffstat (limited to 'ui/jquery.ui.dialog.js')
-rw-r--r--ui/jquery.ui.dialog.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js
index 2b9846b3a..6617c344e 100644
--- a/ui/jquery.ui.dialog.js
+++ b/ui/jquery.ui.dialog.js
@@ -248,6 +248,13 @@ $.widget("ui.dialog", {
this.overlay.destroy();
}
+ 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();
+ }
+
if ( this.options.hide ) {
this._hide( this.uiDialog, this.options.hide, function() {
that._trigger( "close", event );
@@ -278,6 +285,8 @@ $.widget("ui.dialog", {
options = this.options,
uiDialog = this.uiDialog;
+ this.opener = $( this.document[ 0 ].activeElement );
+
this._size();
this._position( options.position );
uiDialog.show( options.show );