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/tests/phpunit/tests/customize/nav-menus.php

    r56548 r59224  
    770770            foreach ( $post_types as $type ) {
    771771                $this->assertStringContainsString( 'available-menu-items-post_type-' . esc_attr( $type->name ), $template );
    772                 $this->assertMatchesRegularExpression( '#<h4 class="accordion-section-title".*>\s*' . esc_html( $type->labels->name ) . '#', $template );
     772                $this->assertMatchesRegularExpression( '#<h4 class="accordion-section-title".*>\s*<button type="button" class="accordion-trigger" aria-expanded="false" aria-controls=".*">\s*' . esc_html( $type->labels->name ) . '#', $template );
    773773                $this->assertStringContainsString( 'data-type="post_type"', $template );
    774774                $this->assertStringContainsString( 'data-object="' . esc_attr( $type->name ) . '"', $template );
     
    781781            foreach ( $taxonomies as $tax ) {
    782782                $this->assertStringContainsString( 'available-menu-items-taxonomy-' . esc_attr( $tax->name ), $template );
    783                 $this->assertMatchesRegularExpression( '#<h4 class="accordion-section-title".*>\s*' . esc_html( $tax->labels->name ) . '#', $template );
     783                $this->assertMatchesRegularExpression( '#<h4 class="accordion-section-title".*>\s*<button type="button" class="accordion-trigger" aria-expanded="false" aria-controls=".*">\s*' . esc_html( $tax->labels->name ) . '#', $template );
    784784                $this->assertStringContainsString( 'data-type="taxonomy"', $template );
    785785                $this->assertStringContainsString( 'data-object="' . esc_attr( $tax->name ) . '"', $template );
     
    789789
    790790        $this->assertStringContainsString( 'available-menu-items-custom_type', $template );
    791         $this->assertMatchesRegularExpression( '#<h4 class="accordion-section-title".*>\s*Custom#', $template );
     791        $this->assertMatchesRegularExpression( '#<h4 class="accordion-section-title".*>\s*<button type="button" class="accordion-trigger" aria-expanded="false" aria-controls=".*">\s*Custom#', $template );
    792792        $this->assertStringContainsString( 'data-type="custom_type"', $template );
    793793        $this->assertStringContainsString( 'data-object="custom_object"', $template );
Note: See TracChangeset for help on using the changeset viewer.