Navigation Block: Let flex-grow/flex-basis be applied to the List Items#68780
Navigation Block: Let flex-grow/flex-basis be applied to the List Items#68780yogeshbhutkar wants to merge 4 commits into
flex-grow/flex-basis be applied to the List Items#68780Conversation
|
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 Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @Pixelous. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Sorry for the late reply. From what I understand, this issue occurs not only for Grow width ( A completely different approach may be to apply Example code changes to the trunk branchdiff --git a/packages/block-library/src/navigation/index.php b/packages/block-library/src/navigation/index.php
index bde3ee4038..11d04c18bc 100644
--- a/packages/block-library/src/navigation/index.php
+++ b/packages/block-library/src/navigation/index.php
@@ -151,7 +151,7 @@ class WP_Navigation_Block_Renderer {
$inner_block_content = $inner_block->render();
if ( ! empty( $inner_block_content ) ) {
if ( static::does_block_need_a_list_item_wrapper( $inner_block ) ) {
- return '<li class="wp-block-navigation-item">' . $inner_block_content . '</li>';
+ return '<li class="wp-block-navigation-item wp-block-navigation-item__wrapper">' . $inner_block_content . '</li>';
}
}
diff --git a/packages/block-library/src/navigation/style.scss b/packages/block-library/src/navigation/style.scss
index 17ca8de9a7..822af4b711 100644
--- a/packages/block-library/src/navigation/style.scss
+++ b/packages/block-library/src/navigation/style.scss
@@ -39,6 +39,10 @@ $navigation-icon-size: 24px;
.wp-block-navigation__submenu-container:empty {
display: none;
}
+
+ &.wp-block-navigation-item__wrapper {
+ display: contents;
+ }
}
// Menu item link.@fabiankaegy, @getdave, and @scruffian may have some ideas. PR Summary: In the Navigation block, blocks defined in $needs_list_item_wrapper are wrapped in a list element. As a result, even if you set Grow, Fixed widths on those blocks, they will not be applied correctly because they are not children of the flex layout. This PR is an attempt to solve the issue by adding inline styles for widths to the list item wrappers. |
beeab32 to
07ad518
Compare
selfStretch within list item wrapperflex-grow/flex-basis be applied to the List Items
|
Thanks for the review, @t-hamano .
This approach seems to be the best solution to the issue. I've refreshed the PR to reflect the same. It works well in both scenarios: when the width is set to grow and when it's fixed. Ref: pr-demo.movNote: The failing tests are not related to the changes introduced in this PR and should pass on re-run. |
t-hamano
left a comment
There was a problem hiding this comment.
This approach seems to work best for me and won't cause any issues.
However, I'm not 100% confident in it, so I'd appreciate a second feedback from someone more knowledgeable.
|
@MaggieCabrera and @mikachan have a lot of experience with Themes and may be able to verify this approach. |
|
I need to look at this closer but I'm concerned for the extra added class, it's something we need to commit to so we gotta be very sure about it |
Thinking about this more and looking closer at the implementation here, the extra class seems to make sense in this context. My main worry is that the CSS doesn't seem to be working consistently on the site editor and frontend like my previous comment shows. |
|
Thanks for testing. I'll have a look and try to figure out the root cause. |
|
|
I was able to reproduce this issue. I can also confirm that this happens on the latest I believe it happens because of the way the markup is structured. I found that the button is not a child of navigation container (a |
|
I realized that the approach using the
It seems that there is a possibility to disable semantics in Safari browser. Unfortunately, I can't test it because I'm a Windows user. Can someone test if this browser bug still occurs? |
Yes, it's not recommended to use I'm not sure what the best solution is. Ideally the child layout styles would be applied to the We have the same bug with site title and site logo btw, for the same reasons. |



What, Why and How?
Fixes: #68753
This PR addresses a bug where the
flex-growproperty does not work as expected for blocks, such associal links, nested within thecore/navigationblock. The issue arises because these blocks are wrapped in a list item (<li>) element, which prevents theflex-growstyle from being applied effectively.Testing Instructions
social links blockinside acore/navigationblock.width growfeature for thesocial linksblock.flex-grow.Screencast
Screen.Recording.2025-01-20.at.3.04.53.PM.mov