-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Navigation: Don't save the level of the link in an attribute #48219
Conversation
Size Change: -22 B (0%) Total Size: 1.34 MB
ℹ️ View Unchanged
|
Flaky tests detected in b8a2b93. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4323410848
|
* @param array $attributes Block attributes. | ||
* @return array Colors CSS classes and inline styles. | ||
*/ | ||
function block_core_navigation_link_build_css_colors( $context, $attributes ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why this was duplicated. I'd rather use the same function in both places. If we need to keep two copies of it, I'm not sure what we should do with this one - it never uses the $is_sub_menu branch, so we could just remove all that, but then it diverges from block_core_navigation_submenu_build_css_colors
.
edf02fc
to
bd2be17
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested this and couldn't find any regressions. I would prefer if we had a few more manual tests confirming the same.
I'm going to cautiously approve though as I think this fix is critical for fixing numerous bugs.
@ntsekouras @Mamaduka I've added the backport label to this PR as I believe we need it to fix several bugs. I would prefer if more people could test it before it gets merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is working as expected!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a bug when moving a submenu item to top level, it gets rendered with submenu item colors - not happening on trunk
for me:
submenu-reder.mp4
I have fixed that bug in 623d6f5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a good change and in my testing it works as described.
623d6f5
to
b8a2b93
Compare
🍾 🍾 🍾 🍾 🍾 🍾 |
* Don't save the level of the link in an attribute * reuse code * remove duplicate code * add extra escaping * Remove refactoring * update the doc block * fix linter * fix linter * remove double escape * Use existing truthy var for clarity in function call * Navigation Link blocks don't need submenu colors as this is set in the submenu block * fix linter --------- Co-authored-by: Dave Smith <[email protected]>
I just cherry-picked this PR to the wp/6.2 branch to get it included in the next release: e749760 |
What?
The useEffect that saves the
isTopLevelLink
andisTopLevelItem
to an attribute causes ripples through the other useEffects in the navigation block, which means that we get unexpected bugs like those listed below.I don't think we need this useEffect at all - we don't even need to know if this is a top level link. Instead we can output the colors on the navigation submenu wrapper element itself.
Closes #47829
Closes #48594
Closes #48668
Why?
I think this is a simpler approach and avoids the needs for a useEffect and extra attributes.
Testing Instructions
Testing Instructions for Keyboard
I suppose you'll have to inspect the code to ensure that the correct colors are applied.
Screenshots or screencast
Here are some disgusting colors: