Make WordPress Core


Ignore:
Timestamp:
06/27/2019 12:32:28 PM (7 years ago)
Author:
afercia
Message:

Accessibility: Make the Media modal an ARIA modal dialog.

For a number of years, the Media modal missed an explicit ARIA role and the required attributes for modal dialogs.

This was confusing for assistive technology users, since they may not realize they're inside a dialog, and that consequently the keyboard interactions may be different from the rest of the page. Lack of an explicit label for the dialog was confusing as well, since assistive technology users didn't have an immediate sense of what the dialog is for.

This change makes the Media modal meet the ARIA Authoring Practices recommendations, helping users better understand the purpose and interactions with the modal. Also, it makes sure to hide the rest of the page content from assistive technologies, until support for aria-modal="true" improves.

Additionally:

  • moves the modal H1 heading to the beginning of the modal content
  • changes the modal left menu position to make visual and DOM order match
  • improves the wp.media.view.FocusManager documentation

Fixes #47145.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/media-template.php

    r45524 r45572  
    178178        <?php // Template for the media frame: used both in the media grid and in the media modal. ?>
    179179        <script type="text/html" id="tmpl-media-frame">
     180                <div class="media-frame-title" id="media-frame-title"></div>
    180181                <div class="media-frame-menu"></div>
    181                 <div class="media-frame-title"></div>
    182182                <div class="media-frame-router"></div>
    183183                <div class="media-frame-content"></div>
    … …  
    188188        <?php // Template for the media modal. ?>
    189189        <script type="text/html" id="tmpl-media-modal">
    190                 <div tabindex="0" class="<?php echo $class; ?>">
     190                <div tabindex="0" class="<?php echo $class; ?>" role="dialog" aria-modal="true" aria-labelledby="media-frame-title">
    191191                        <# if ( data.hasCloseButton ) { #>
    192192                                <button type="button" class="media-modal-close"><span class="media-modal-icon"><span class="screen-reader-text"><?php _e( 'Close dialog' ); ?></span></span></button>
    193193                        <# } #>
    194                         <div class="media-modal-content"></div>
     194                        <div class="media-modal-content" role="document"></div>
    195195                </div>
    196196                <div class="media-modal-backdrop"></div>
Note: See TracChangeset for help on using the changeset viewer.