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-includes/class-wp-customize-nav-menus.php

    r58306 r59224  
    12241224        <div id="<?php echo esc_attr( $id ); ?>" class="accordion-section">
    12251225            <h4 class="accordion-section-title" role="presentation">
    1226                 <?php echo esc_html( $available_item_type['title'] ); ?>
    1227                 <span class="spinner"></span>
    1228                 <span class="no-items"><?php _e( 'No items' ); ?></span>
    1229                 <button type="button" class="button-link" aria-expanded="false">
    1230                     <span class="screen-reader-text">
    1231                     <?php
    1232                         /* translators: %s: Title of a section with menu items. */
    1233                         printf( __( 'Toggle section: %s' ), esc_html( $available_item_type['title'] ) );
    1234                     ?>
    1235                         </span>
     1226                <button type="button" class="accordion-trigger" aria-expanded="false" aria-controls="<?php echo esc_attr( $id ); ?>-content">
     1227                    <?php echo esc_html( $available_item_type['title'] ); ?>
     1228                    <span class="spinner"></span>
     1229                    <span class="no-items"><?php _e( 'No items' ); ?></span>
    12361230                    <span class="toggle-indicator" aria-hidden="true"></span>
    12371231                </button>
    12381232            </h4>
    1239             <div class="accordion-section-content">
     1233            <div class="accordion-section-content" id="<?php echo esc_attr( $id ); ?>-content">
    12401234                <?php if ( 'post_type' === $available_item_type['type'] ) : ?>
    12411235                    <?php $post_type_obj = get_post_type_object( $available_item_type['object'] ); ?>
     
    12651259        <div id="new-custom-menu-item" class="accordion-section">
    12661260            <h4 class="accordion-section-title" role="presentation">
    1267                 <?php _e( 'Custom Links' ); ?>
    1268                 <button type="button" class="button-link" aria-expanded="false">
    1269                     <span class="screen-reader-text">
    1270                         <?php
    1271                         /* translators: Hidden accessibility text. */
    1272                         _e( 'Toggle section: Custom Links' );
    1273                         ?>
    1274                     </span>
     1261                <button type="button" class="accordion-trigger" aria-expanded="false" aria-controls="new-custom-menu-item-content">
     1262                    <?php _e( 'Custom Links' ); ?>
    12751263                    <span class="toggle-indicator" aria-hidden="true"></span>
    12761264                </button>
    12771265            </h4>
    1278             <div class="accordion-section-content customlinkdiv">
     1266            <div class="accordion-section-content customlinkdiv" id="new-custom-menu-item-content">
    12791267                <input type="hidden" value="custom" id="custom-menu-item-type" name="menu-item[-1][menu-item-type]" />
    12801268                <p id="menu-item-url-wrap" class="wp-clearfix">
Note: See TracChangeset for help on using the changeset viewer.