Permalink
Browse files

Dialog: Return focus to dialog when window regains focus. Partial fix…

… for #7862 - modal accessibility
  • Loading branch information...
1 parent 80a6188 commit fe5f67392b961f7672a2a6449f768c13e6891a88 @larowlan committed Jul 18, 2012
Showing with 13 additions and 0 deletions.
  1. +13 −0 ui/jquery.ui.dialog.js
@@ -754,6 +754,19 @@ $.extend( $.ui.dialog.overlay, {
}
});
+ // allow refocussing topmost dialog when window receives focus
+ $( window ).bind( "focus.dialog-overlay", function( event ) {
+ var instances = $.ui.dialog.overlay.instances;
+ // only react to the event if we're the top overlay
+ if ( instances.length !== 0 && instances[ instances.length - 1 ] === $el &&
+ dialog.options.modal && !event.isDefaultPrevented()) {
+
+ var tabbables = $( ":tabbable", dialog.uiDialog ),
+ first = tabbables.filter( ":first" );
+ first.focus(1);
+ }
+ });
+
$el.appendTo( document.body ).css({
width: this.width(),
height: this.height()

0 comments on commit fe5f673

Please sign in to comment.