Skip to content

Commit

Permalink
Align Submenu block and Nav Link block by including description and w…
Browse files Browse the repository at this point in the history
…rapping span (WordPress#67198)

* Fix missing wp-block-navigation-item__label span

* Addressed feedback

* Updated README.md

Co-authored-by: prajapatisagar <[email protected]>
Co-authored-by: MaggieCabrera <[email protected]>
Co-authored-by: getdave <[email protected]>
Co-authored-by: carolinan <[email protected]>
  • Loading branch information
5 people authored and im3dabasia committed Dec 4, 2024
1 parent 41f46f1 commit 8b6e403
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/block-library/src/navigation-submenu/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,11 @@ export default function NavigationSubmenuEdit( {
}
} }
/>
{ description && (
<span className="wp-block-navigation-item__description">
{ description }
</span>
) }
{ ! openSubmenusOnClick && isLinkOpen && (
<LinkUI
clientId={ clientId }
Expand Down
16 changes: 16 additions & 0 deletions packages/block-library/src/navigation-submenu/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,16 @@ function render_block_core_navigation_submenu( $attributes, $content, $block ) {
$html .= '>';
// End appending HTML attributes to anchor tag.

$html .= '<span class="wp-block-navigation-item__label">';
$html .= $label;
$html .= '</span>';

// Add description if available.
if ( ! empty( $attributes['description'] ) ) {
$html .= '<span class="wp-block-navigation-item__description">';
$html .= wp_kses_post( $attributes['description'] );
$html .= '</span>';
}

$html .= '</a>';
// End anchor tag content.
Expand All @@ -180,6 +189,13 @@ function render_block_core_navigation_submenu( $attributes, $content, $block ) {

$html .= '</span>';

// Add description if available.
if ( ! empty( $attributes['description'] ) ) {
$html .= '<span class="wp-block-navigation-item__description">';
$html .= wp_kses_post( $attributes['description'] );
$html .= '</span>';
}

$html .= '</button>';

$html .= '<span class="wp-block-navigation__submenu-icon">' . block_core_navigation_submenu_render_submenu_icon() . '</span>';
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/navigation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ The structural CSS for the navigation block targets generic classnames across me
- `.wp-block-navigation-item` is applied to every menu item.
- `.wp-block-navigation-item__content` is applied to the link inside a menu item.
- `.wp-block-navigation-item__label` is applied to the innermost container around the menu item text label.
- `.wp-block-navigation-item__description` is applied to the innermost container around the menu item description.
- `.wp-block-navigation__submenu-icon` is applied to the submenu indicator (chevron).

0 comments on commit 8b6e403

Please sign in to comment.