Skip to content

Commit

Permalink
Add a current-menu-ancestor class to menus
Browse files Browse the repository at this point in the history
  • Loading branch information
aristath committed May 3, 2022
1 parent 739b871 commit 8d81526
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/block-library/src/navigation-submenu/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,10 @@ function render_block_core_navigation_submenu( $attributes, $content, $block ) {
$inner_blocks_html .= $inner_block->render();
}

if ( strpos( $inner_blocks_html, 'current-menu-item' ) ) {
$html = str_replace( 'wp-block-navigation-item__content', 'wp-block-navigation-item__content current-menu-ancestor', $html );
}

$html .= sprintf(
'<ul class="wp-block-navigation__submenu-container">%s</ul>',
$inner_blocks_html
Expand Down

0 comments on commit 8d81526

Please sign in to comment.