Skip to content

Commit 1d0d50a

Browse files
committed
Dialog: Improve accessibilty - add an aria-describedby attribute on the dialog if there is nothing yet in the dialog content. Partial fix for:
1 parent 9473ea7 commit 1d0d50a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

ui/jquery.ui.dialog.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,15 @@ $.widget("ui.dialog", {
156156
"aria-labelledby": uiDialogTitle.attr( "id" )
157157
});
158158

159+
// We assume that any existing aria-describedby attribute means
160+
// that the dialog content is marked up properly
161+
// otherwise we brute force the content as the description
162+
if ( !this.element.find( "[aria-describedby]" ).length ) {
163+
uiDialog.attr({
164+
"aria-describedby": this.element.uniqueId().attr( "id" )
165+
});
166+
}
167+
159168
uiDialogTitlebar.find( "*" ).add( uiDialogTitlebar ).disableSelection();
160169
this._hoverable( uiDialogTitlebarClose );
161170
this._focusable( uiDialogTitlebarClose );
@@ -205,6 +214,7 @@ $.widget("ui.dialog", {
205214
}
206215
this.uiDialog.hide();
207216
this.element
217+
.removeUniqueId()
208218
.removeClass( "ui-dialog-content ui-widget-content" )
209219
.hide()
210220
.appendTo( "body" );

0 commit comments

Comments
 (0)