diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index 496118761d0..c57e8e3400c 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -68,7 +68,8 @@ $.widget("ui.dialog", { stack: true, title: "", width: 300, - zIndex: 1000 + zIndex: 1000, + focusOnClose: false }, _create: function() { @@ -228,6 +229,10 @@ $.widget("ui.dialog", { }); $.ui.dialog.maxZ = maxZ; } + // restore focus of underlying page, unless overidden at some point while the dialog is open. + if (self.options.focusOnClose){ + $(self.options.focusOnClose).focus(); + } return self; }, @@ -281,6 +286,10 @@ $.widget("ui.dialog", { options = self.options, uiDialog = self.uiDialog; + // store the element with the current focus, so it can be restored when the dialog closes. Also force a Blur event to it. requires jquery core 1.6 + self.options.focusOnClose = $(":focus"); + $(self.options.focusOnClose).blur(); + self._size(); self._position( options.position ); uiDialog.show( options.show );