-
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 Submenu: Fix color handling and inheritance #68351
base: trunk
Are you sure you want to change the base?
Navigation Submenu: Fix color handling and inheritance #68351
Conversation
…failing test case
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 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. |
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.
@yogeshbhutkar Background color for sub menu block is not getting applied I think, Can you recheck?
https://github.com/user-attachments/assets/c561b8c3-cf34-41db-9fa9-effd6511aaa2
@@ -99,6 +99,16 @@ function render_block_core_navigation_submenu( $attributes, $content, $block ) { | |||
$open_on_hover_and_click = isset( $block->context['openSubmenusOnClick'] ) && ! $block->context['openSubmenusOnClick'] && | |||
$show_submenu_indicators; | |||
|
|||
$block->block_type->supports['color'] = true; |
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.
Repeated again on line 258, is there a reason we need to set twice?
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.
The repetition on line 258 could be omitted safely. Will be done in the next commit. Thanks for the suggestion.
'has-background': !! backgroundColor || customBackgroundColor, | ||
[ getColorClassName( 'background-color', backgroundColor ) ]: | ||
!! backgroundColor, | ||
'has-text-color': !! _textColor || !! _customTextColor, |
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.
"textColor": {
"type": "string"
},
Since its a string, I feel this is a little less readable on first glance.
Maybe adding a explicit check might be better?
'has-text-color': Boolean(_textColor || _customTextColor),
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 the Double Bang
operator conveys the boolean nature and should provide sufficient context.
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.
Fair enough, but the original included two comparisons, whereas this approach reduces it to just one.
What, Why & How?
Testing Instructions for Keyboard
Screencasts
The following are the expected outcomes that the submenu block should abide by.
If the
navigation block
has either abackground
or atext
color assigned, and there's no color provided for thesubmenu & overlay text
orsubmenu & overlay background
, thennavigation
blocks color should be inherited. ( ✅ )If the
navigation block
has specified a color, but, thesubmenu parent
has also specified a color (background and text ), the submenu container should still inherit the color from thenavigation block
. ( ✅ )If
submenu & overlay text
orsubmenu & overlay background
values are provided, these should overwrite the values ofnavigation block
. ( ✅ )if only
submenu's
color and background value are passed, then it shouldn't override the value of thesubmenu container
.Container's
values must be either inherited fromnavigation
or from the dedicatedsubmenu
control options onnavigation
. ( ✅ )Closes: #68350