Accessibility: Hide the Toolbar sub-menu CSS generated icons from assistive technologies.
CSS generated content is rendered for speech output. When it's not meant to be announced by assistive technologies, for example with font icons, special care should be used to hide it. 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. Built from https://develop.svn.wordpress.org/trunk@44793 git-svn-id: http://core.svn.wordpress.org/trunk@44625 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -501,14 +501,17 @@ class WP_Admin_Bar {
|
||||
return;
|
||||
}
|
||||
|
||||
$is_parent = ! empty( $node->children );
|
||||
$has_link = ! empty( $node->href );
|
||||
$is_parent = ! empty( $node->children );
|
||||
$has_link = ! empty( $node->href );
|
||||
$is_root_top_item = 'root-default' === $node->parent;
|
||||
$is_top_secondary_item = 'top-secondary' === $node->parent;
|
||||
|
||||
// Allow only numeric values, then casted to integers, and allow a tabindex value of `0` for a11y.
|
||||
$tabindex = ( isset( $node->meta['tabindex'] ) && is_numeric( $node->meta['tabindex'] ) ) ? (int) $node->meta['tabindex'] : '';
|
||||
$aria_attributes = ( '' !== $tabindex ) ? ' tabindex="' . $tabindex . '"' : '';
|
||||
|
||||
$menuclass = '';
|
||||
$arrow = '';
|
||||
|
||||
if ( $is_parent ) {
|
||||
$menuclass = 'menupop ';
|
||||
@@ -519,6 +522,11 @@ class WP_Admin_Bar {
|
||||
$menuclass .= $node->meta['class'];
|
||||
}
|
||||
|
||||
// Print the arrow icon for the menu children with children.
|
||||
if ( ! $is_root_top_item && ! $is_top_secondary_item && $is_parent ) {
|
||||
$arrow = '<span class="wp-admin-bar-arrow" aria-hidden="true"></span>';
|
||||
}
|
||||
|
||||
if ( $menuclass ) {
|
||||
$menuclass = ' class="' . esc_attr( trim( $menuclass ) ) . '"';
|
||||
}
|
||||
@@ -542,7 +550,7 @@ class WP_Admin_Bar {
|
||||
}
|
||||
}
|
||||
|
||||
echo ">{$node->title}";
|
||||
echo ">{$arrow}{$node->title}";
|
||||
|
||||
if ( $has_link ) {
|
||||
echo '</a>';
|
||||
|
||||
Reference in New Issue
Block a user