Permalink
Browse files

Dialog: Don't assign role=dialog for non-modal dialogs, don't use rol…

…e=document for non modals. Partial fix for #7862 - modal accessibility
  • Loading branch information...
1 parent f0db812 commit 80a6188d70e8696ce1dd7176e776e7a1f82db1ae @larowlan committed Jul 15, 2012
Showing with 13 additions and 7 deletions.
  1. +1 −1 demos/dialog/animated.html
  2. +12 −6 ui/jquery.ui.dialog.js
@@ -28,7 +28,7 @@
});
$( "#opener" ).click(function() {
- $( "#dialog" ).dialog( "open" );
+ $( "#dialog" ).dialog( "open", $(this));
return false;
});
});
View
@@ -111,21 +111,21 @@ $.widget("ui.dialog", {
.appendTo( "body" ),
// Add a document wrapper inside the dialog for a11y.
- uiDialogDocument = ( this.uiDialogDocument = $( "<div>" ) )
+ uiDialogDocument = options.modal ? ( this.uiDialogDocument = $( "<div>" ) )
.attr( "role", "document")
.addClass( "ui-dialog-document" )
- .appendTo( uiDialog),
+ .appendTo( uiDialog) : null,
uiDialogContent = this.element
.show()
.removeAttr( "title" )
.addClass( "ui-dialog-content ui-widget-content" )
- .appendTo( uiDialogDocument ),
+ .appendTo( options.modal ? uiDialogDocument : uiDialog ),
uiDialogTitlebar = ( this.uiDialogTitlebar = $( "<div>" ) )
.addClass( "ui-dialog-titlebar ui-widget-header " +
"ui-corner-all ui-helper-clearfix" )
- .prependTo( uiDialogDocument ),
+ .prependTo( options.modal ? uiDialogDocument : uiDialog ),
uiDialogTitlebarClose = $( "<a href='#'></a>" )
.addClass( "ui-dialog-titlebar-close ui-corner-all" )
@@ -154,9 +154,15 @@ $.widget("ui.dialog", {
.addClass( "ui-dialog-buttonset" )
.appendTo( uiDialogButtonPane );
+ if (options.modal) {
+ // We should only sandbox user to dialog if modal (a11y).
+ uiDialog.attr({
+ role: "dialog"
+ });
+ }
uiDialog.attr({
- role: "dialog",
- "aria-labelledby": uiDialogTitle.attr( "id" )
+ "aria-labelledby": uiDialogTitle.attr( "id" ),
+ "aria-describedby": uiDialogContent.attr( "id" )
});
uiDialogTitlebar.find( "*" ).add( uiDialogTitlebar ).disableSelection();

0 comments on commit 80a6188

Please sign in to comment.