Make WordPress Core


Ignore:
Timestamp:
10/13/2024 07:07:06 PM (5 months ago)
Author:
joedolson
Message:

Administration: A11y: Fix accordion accessibility.

Change accordions in the customizer and the navigation menus to make proper usage of accordion markup patterns. This includes adding missing :focus states, using a button element to control tabbing and interaction, instead of the heading elements, and removing instructional text for screen reader users that was used to compensate for the incorrect markup pattern.

Props afercia, rishishah, kushang78, rcreators, krupajnanda, hmbashar, joedolson.
Fixes #42002.

File:
1 edited

Legend:

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

    r59114 r59224  
    15671567                    $hidden_class = in_array( $box['id'], $hidden, true ) ? 'hide-if-js' : '';
    15681568
    1569                     $open_class = '';
     1569                    $open_class    = '';
     1570                    $aria_expanded = 'false';
    15701571                    if ( ! $first_open && empty( $hidden_class ) ) {
    1571                         $first_open = true;
    1572                         $open_class = 'open';
     1572                        $first_open    = true;
     1573                        $open_class    = 'open';
     1574                        $aria_expanded = 'true';
    15731575                    }
    15741576                    ?>
    15751577                    <li class="control-section accordion-section <?php echo $hidden_class; ?> <?php echo $open_class; ?> <?php echo esc_attr( $box['id'] ); ?>" id="<?php echo esc_attr( $box['id'] ); ?>">
    1576                         <h3 class="accordion-section-title hndle" tabindex="0">
    1577                             <?php echo esc_html( $box['title'] ); ?>
    1578                             <span class="screen-reader-text">
    1579                                 <?php
    1580                                 /* translators: Hidden accessibility text. */
    1581                                 _e( 'Press return or enter to open this section' );
    1582                                 ?>
    1583                             </span>
     1578                        <h3 class="accordion-section-title hndle">
     1579                            <button type="button" class="accordion-trigger" aria-expanded="<?php echo $aria_expanded; ?>" aria-controls="<?php echo esc_attr( $box['id'] ); ?>-content">
     1580                                <span class="accordion-title">
     1581                                    <?php echo esc_html( $box['title'] ); ?>
     1582                                    <span class="dashicons dashicons-arrow-down" aria-hidden="true"></span>
     1583                                </span>
     1584                            </button>
    15841585                        </h3>
    1585                         <div class="accordion-section-content <?php postbox_classes( $box['id'], $page ); ?>">
     1586                        <div class="accordion-section-content <?php postbox_classes( $box['id'], $page ); ?>" id="<?php echo esc_attr( $box['id'] ); ?>-content">
    15861587                            <div class="inside">
    15871588                                <?php call_user_func( $box['callback'], $data_object, $box ); ?>
Note: See TracChangeset for help on using the changeset viewer.