Archived topic
Accessibility checker - Search bar
4 replies · Started by Harris on December 18, 2019
Hello
Any workaround to ommit this "error" from achecker.ca
As far as I understand it comes from the search funcionality in the header.
https://i.gyazo.com/55b5901f3fd835c80d849e343e1bf1f7.png
Thanks!
Hi there,
That element indeed has no text, but it does have an aria-label attribute, which makes it so text isn't necessary.
I think you can safely ignore that one :)
Hello Tom,
Thanks for your reply. I know that it doesn't cause a problem, but I need to provide to the client an error free report from this tool, so if there is any kind of workaround please let me know.
In order to "fix" the error, you would need to remove the current menu item and add your own with text.
To do that, you can do this:
remove_filter( 'wp_nav_menu_items', 'generate_menu_search_icon', 10, 2 );
add_filter( 'wp_nav_menu_items', function( $items, $args ) {
if ( isset( $args->theme_location ) && 'primary' === $args->theme_location ) {
return sprintf(
'%1$s<li class="search-item"><a aria-label="%2$s" href="#">%3$s Search</a></li>',
$items,
esc_attr__( 'Open Search Bar', 'generatepress' ),
generate_get_svg_icon( 'search', true )
);
}
return $items;
}, 10, 2 );
Thanks Tom! I will give it a go!
I know it is not an error but there are some E.U. programs funding website builds that require error free reports from a couple of checkers including achecker.