Skip to content

Commit

Permalink
Global header, Local navigation: Add aria label to the main, search, …
Browse files Browse the repository at this point in the history
…and local nav blocks (#634)

* Global header: Add aria label to the main and search nav blocks

Fixes #622

* Local navigation: Add aria label to menu inside block
  • Loading branch information
ryelle authored Jul 2, 2024
1 parent f7c1425 commit d2022e0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mu-plugins/blocks/global-header-footer/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function recursive_menu( $menu_item, $top_level = true ) {
<!-- /wp:paragraph -->
<?php endif; ?>

<!-- wp:navigation {"openSubmenusOnClick":true,"className":"global-header__navigation","layout":{"type":"flex","orientation":"horizontal"}} -->
<!-- wp:navigation {"openSubmenusOnClick":true,"className":"global-header__navigation","ariaLabel":"<?php echo esc_attr_x( 'Main', 'main navigation label', 'wporg' ); ?>","layout":{"type":"flex","orientation":"horizontal"}} -->
<?php
/*
* Loop though menu items and create navigation item blocks. Recurses through any submenu items to output dropdowns.
Expand All @@ -99,7 +99,7 @@ function recursive_menu( $menu_item, $top_level = true ) {
calls for. It also provides a consistent experience with the primary navigation menu, with respect to
keyboard navigation, ARIA states, etc. It also saves having to write custom code for all the interactions.
-->
<!-- wp:navigation {"className":"global-header__search","layout":{"type":"flex","orientation":"vertical"},"overlayMenu":"always"} -->
<!-- wp:navigation {"className":"global-header__search","ariaLabel":"<?php echo esc_attr_x( 'Search', 'search toggle navigation label', 'wporg' ); ?>","layout":{"type":"flex","orientation":"vertical"},"overlayMenu":"always"} -->
<!-- wp:search <?php echo wp_json_encode( $search_args ); ?> /-->
<!-- /wp:navigation -->
<?php endif; ?>
Expand Down
1 change: 1 addition & 0 deletions mu-plugins/blocks/local-navigation-bar/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ function update_child_block_attributes( $parsed_block, $source_block, $parent_bl
'type' => 'flex',
'orientation' => 'horizontal',
);
$parsed_block['attrs']['ariaLabel'] = _x( 'Section', 'local navigation label', 'wporg' );

// Add an extra navigation block which is always collapsed, so that it
// can be swapped out when the section title + nav menu collide.
Expand Down

0 comments on commit d2022e0

Please sign in to comment.