Skip to content

Commit 6cc9480

Browse files
committed
Accessibility: Hide the Toolbar sub-menu icons from assistive technologies.
CSS generated content is going to be rendered for speech output more and more in the next future. When it's not intended to be available for speech output, for example with font icons, then special care should be used to hide it from assistive technologies. At the moment, the only reliable way to do this is making use of a wrapper element and set `aria-hidden="true"` on it. Fixes #37513. git-svn-id: https://develop.svn.wordpress.org/trunk@38984 602fd350-edb4-49c9-b593-d223f7449a82
1 parent cc6925d commit 6cc9480

2 files changed

Lines changed: 17 additions & 8 deletions

File tree

src/wp-includes/class-wp-admin-bar.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -474,20 +474,27 @@ final protected function _render_item( $node ) {
474474
if ( $node->type != 'item' )
475475
return;
476476

477-
$is_parent = ! empty( $node->children );
478-
$has_link = ! empty( $node->href );
477+
$is_parent = ! empty( $node->children );
478+
$has_link = ! empty( $node->href );
479+
$is_root_top_item = 'root-default' === $node->parent;
480+
$is_top_secondary_item = 'top-secondary' === $node->parent;
479481

480482
// Allow only numeric values, then casted to integers, and allow a tabindex value of `0` for a11y.
481483
$tabindex = ( isset( $node->meta['tabindex'] ) && is_numeric( $node->meta['tabindex'] ) ) ? (int) $node->meta['tabindex'] : '';
482484
$aria_attributes = ( '' !== $tabindex ) ? ' tabindex="' . $tabindex . '"' : '';
483485

484-
$menuclass = '';
486+
$menuclass = $arrow_right = '';
485487

486488
if ( $is_parent ) {
487489
$menuclass = 'menupop ';
488490
$aria_attributes .= ' aria-haspopup="true"';
489491
}
490492

493+
// Print the right arrow icon for the primary menu children with children.
494+
if ( ! $is_root_top_item && ! $is_top_secondary_item && $is_parent ) {
495+
$arrow_right = '<span class="wp-admin-bar-arrow-right" aria-hidden="true"></span>';
496+
}
497+
491498
if ( ! empty( $node->meta['class'] ) )
492499
$menuclass .= $node->meta['class'];
493500

@@ -532,7 +539,7 @@ final protected function _render_item( $node ) {
532539
?>><?php
533540
endif;
534541

535-
echo $node->title;
542+
echo $arrow_right . $node->title;
536543

537544
if ( $has_link ) :
538545
?></a><?php

src/wp-includes/css/admin-bar.css

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,8 @@ html:lang(he-il) .rtl #wpadminbar * {
234234

235235
#wpadminbar > #wp-toolbar > #wp-admin-bar-root-default .ab-icon,
236236
#wpadminbar .ab-icon,
237-
#wpadminbar .ab-item:before {
237+
#wpadminbar .ab-item:before,
238+
.wp-admin-bar-arrow-right {
238239
position: relative;
239240
float: left;
240241
font: normal 20px/1 dashicons;
@@ -312,7 +313,7 @@ html:lang(he-il) .rtl #wpadminbar * {
312313
color: #00b9eb;
313314
}
314315

315-
#wpadminbar .menupop .menupop > .ab-item:before,
316+
#wpadminbar .menupop .menupop > .ab-item .wp-admin-bar-arrow-right:before,
316317
#wpadminbar .ab-top-secondary .menupop .menupop > .ab-item:before {
317318
position: absolute;
318319
font: normal 17px/1 dashicons;
@@ -326,9 +327,10 @@ html:lang(he-il) .rtl #wpadminbar * {
326327
padding-right: 2em;
327328
}
328329

329-
#wpadminbar .menupop .menupop > .ab-item:before {
330+
#wpadminbar .menupop .menupop > .ab-item .wp-admin-bar-arrow-right:before {
330331
top: 1px;
331-
right: 4px;
332+
right: 10px;
333+
padding: 4px 0;
332334
content: "\f139";
333335
color: inherit;
334336
}

0 commit comments

Comments
 (0)