Make WordPress Core


Ignore:
Timestamp:
02/26/2024 12:50:22 AM (16 months ago)
Author:
joedolson
Message:

Toolbar: Accessibility: Keyboard navigation for screen readers.

Change the admin toolbar to have role="menu" and support opening for screen readers. Remove screen reader only log out link and collapse duplicate profile links into one link. This is an imperfect solution to a complex problem in the adminbar, but the lack of screen reader access to submenus is a major accessibility problem, and this fix provides access, even if the mechanism is imperfect.

Screen reader log out added in [21452].

Props abletec, Cheffheid, sabernhardt, alexstine, joedolson, afercia, sparklingrobots, danieltj, swissspidy, netweb, dionysous.
Fixes #34668, #43633.

File:
1 edited

Legend:

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

    r57600 r57708  
    140140            '</span>',
    141141        'href'  => $about_url,
     142        'meta' => array(
     143            'menu_title' => __( 'About WordPress' ),
     144        ),
    142145    );
    143146
     
    283286            'href'   => $profile_url,
    284287            'meta'   => array(
    285                 'class' => $class,
     288                'class'      => $class,
     289                'menu_title' => sprintf( __( 'Howdy, %s' ), $current_user->display_name ),
    286290            ),
    287291        )
     
    326330    }
    327331
     332    $user_info .= "<span class='edit-profile'>" . __( 'Edit Profile' ) . '</span>';
     333
    328334    $wp_admin_bar->add_node(
    329335        array(
     
    332338            'title'  => $user_info,
    333339            'href'   => $profile_url,
    334             'meta'   => array(
    335                 'tabindex' => -1,
    336             ),
    337         )
    338     );
    339 
    340     if ( false !== $profile_url ) {
    341         $wp_admin_bar->add_node(
    342             array(
    343                 'parent' => 'user-actions',
    344                 'id'     => 'edit-profile',
    345                 'title'  => __( 'Edit Profile' ),
    346                 'href'   => $profile_url,
    347             )
    348         );
    349     }
     340        )
     341    );
    350342
    351343    $wp_admin_bar->add_node(
     
    398390            'title' => $title,
    399391            'href'  => ( is_admin() || ! current_user_can( 'read' ) ) ? home_url( '/' ) : admin_url(),
     392            'meta' => array(
     393                'menu_title' => $title,
     394            ),
    400395        )
    401396    );
     
    995990            'title' => $title,
    996991            'href'  => admin_url( current( array_keys( $actions ) ) ),
     992            'meta' => array(
     993                'menu_title' => _x( 'New', 'admin bar menu group label' ),
     994            ),
    997995        )
    998996    );
Note: See TracChangeset for help on using the changeset viewer.