Permalink
Browse files

Dialog: Removes return focus to dialog when window regains focus, use…

… activeElement for triggerEl storage. Partial fix for #7862 - modal accessibility
  • Loading branch information...
1 parent fe5f673 commit 37fef2c08e26f66ef28a541f73e4e31131d4d8c4 @larowlan committed Jul 19, 2012
Showing with 4 additions and 18 deletions.
  1. +1 −2 demos/dialog/modal-form.html
  2. +3 −16 ui/jquery.ui.dialog.js
@@ -109,7 +109,7 @@
$( "#create-user" )
.button()
.click(function() {
- $( "#dialog-form" ).dialog( "open", $(this));
+ $( "#dialog-form" ).dialog( "open");
});
});
</script>
@@ -161,7 +161,6 @@
<div class="demo-description">
<p>Use a modal dialog to require that the user enter data during a multi-step process. Embed form markup in the content area, set the <code>modal</code> option to true, and specify primary and secondary user actions with the <code>buttons</code> option.</p>
-<p>Note the second argument to the open option enables the focus to return to the triggering element when the dialog is closed, which provides greater accessibility.</p>
</div><!-- End demo-description -->
</body>
View
@@ -312,13 +312,13 @@ $.widget("ui.dialog", {
return this;
},
- open: function(triggerEl) {
+ open: function() {
if ( this._isOpen ) {
return;
}
- if (triggerEl) {
- this.triggerEl = triggerEl
+ if (document.activeElement) {
+ this.triggerEl = $( document.activeElement )
}
var hasFocus,
@@ -754,19 +754,6 @@ $.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 37fef2c

Please sign in to comment.