Skip to content

Navigation: Use the shared icon rendering functions for all navigation blocks#76372

Merged
scruffian merged 3 commits intotrunkfrom
fix/navigation-svg-icon-functions
Mar 12, 2026
Merged

Navigation: Use the shared icon rendering functions for all navigation blocks#76372
scruffian merged 3 commits intotrunkfrom
fix/navigation-svg-icon-functions

Conversation

@scruffian
Copy link
Copy Markdown
Contributor

What?

We have two different definitions for the navigation submenu icon rendering functions. We should combine them into one.

Why?

Less code to maintain

How?

Remove the extra definition, and update the calls to reference the new function

Testing Instructions

Check that navigation blocks with submenus still display the chevron icon - you can replace the icon with some text to verify its working.

@scruffian scruffian self-assigned this Mar 10, 2026
@scruffian scruffian added [Type] Code Quality Issues or PRs that relate to code quality [Block] Navigation Affects the Navigation Block labels Mar 10, 2026
@github-actions github-actions bot added the [Package] Block library /packages/block-library label Mar 10, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 10, 2026

Flaky tests detected in 053b669.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/22954358235
📝 Reported issues:

Copy link
Copy Markdown
Member

@tyxla tyxla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid the PHPCS error, as mentioned in the other PR, you'll need to wrap the prefixed function calls in a if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ) check.

@github-actions
Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: scruffian <scruffian@git.wordpress.org>
Co-authored-by: tyxla <tyxla@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@scruffian
Copy link
Copy Markdown
Contributor Author

To avoid the PHPCS error, as #76077 (comment) in the other PR, you'll need to wrap the prefixed function calls in a if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ) check.

Thanks. Done!

I'm concerned that we're going to end up with a lot of code like this but I guess we can cross that bridge when we come to it.

Comment on lines +244 to +248
if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ) {
$html .= gutenberg_block_core_shared_navigation_render_submenu_icon();
} else {
$html .= block_core_shared_navigation_render_submenu_icon();
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bummer that this is so repetitive, but it's cheap so I don't have a strong opinion against removing the repetition.


if ( isset( $block->context['showSubmenuIcon'] ) && $block->context['showSubmenuIcon'] && $has_submenu ) {
// The submenu icon can be hidden by a CSS rule on the Navigation Block.
$html .= '<span class="wp-block-navigation__submenu-icon">' . block_core_navigation_render_submenu_icon() . '</span>';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that we're not using block_core_navigation_render_submenu_icon, should we remove the require_once of the files we don't use, just like we did in #76077?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I was going to do that in a follow up (I have the PR ready here! #76373)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up sounds good 👍

Copy link
Copy Markdown
Member

@tyxla tyxla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks! 🚀

@scruffian scruffian merged commit 70e47a3 into trunk Mar 12, 2026
43 of 47 checks passed
@scruffian scruffian deleted the fix/navigation-svg-icon-functions branch March 12, 2026 09:53
@github-actions github-actions bot added this to the Gutenberg 22.8 milestone Mar 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Block] Navigation Affects the Navigation Block [Package] Block library /packages/block-library [Type] Code Quality Issues or PRs that relate to code quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants