-
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
Fix: empty style attribute issue in navigation block #62600
Fix: empty style attribute issue in navigation block #62600
Conversation
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: @convolutedkdlkf. 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. |
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 it works as expected 👍
That being said, I'm not sure it's necessary to remove the empty style
tag or if there may be unforeseen side effects, so I'll defer approval until we get other thoughts and/or someone with more context on the navigation block can weigh in. It seems like this shouldn't cause any issues though, and it does produce cleaner markup.
@@ -537,7 +539,7 @@ private static function get_responsive_container_markup( $attributes, $inner_blo | |||
$toggle_aria_label_close, | |||
esc_attr( implode( ' ', $responsive_container_classes ) ), | |||
esc_attr( implode( ' ', $open_button_classes ) ), | |||
esc_attr( safecss_filter_attr( $colors['overlay_inline_styles'] ) ), | |||
( ! empty( $overlay_inline_styles ) ) ? "style=$overlay_inline_styles" : '', |
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 PR isn't working at the moment, this is just missing some quotes around the style to make it a valid html attribute:
( ! empty( $overlay_inline_styles ) ) ? "style=$overlay_inline_styles" : '', | |
( ! empty( $overlay_inline_styles ) ) ? "style=\"$overlay_inline_styles\"" : '', |
To reproduce:
- Set a navigation block to Overlay - 'Always'
- Add some custom colors for the overlay menu
- Save and view the frontend - observe the custom colors aren't applied.
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.
@talldan added missing quotes.
Thanks for suggestion.
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.
Looks great, thanks for your contribution @up1512001!
* Fix: empty style attribute issue in navigation block * update: store overlay style to variable for better readibility and performance * Fix: linting issue * Fix: added missing quotes to make valid markup ---- Unlinked contributors: convolutedkdlkf. Co-authored-by: up1512001 <[email protected]> Co-authored-by: artemiomorales <[email protected]> Co-authored-by: talldan <[email protected]>
I just cherry-picked this PR to the wp/6.6-rc-1 branch to get it included in the next release: f6c7337 |
* Fix: empty style attribute issue in navigation block * update: store overlay style to variable for better readibility and performance * Fix: linting issue * Fix: added missing quotes to make valid markup ---- Unlinked contributors: convolutedkdlkf. Co-authored-by: up1512001 <[email protected]> Co-authored-by: artemiomorales <[email protected]> Co-authored-by: talldan <[email protected]>
@convolutedkdlkf mind sharing your WordPress.org username so I can ensure it appears in the 6.7 credits listing? |
What?
$colors['overlay_inline_styles']
is not empty then only adding style attribute.Why?
#62358
How?
Testing Instructions
wp-block-navigation__responsive-container
previously having empty style will not have style attribute.Screenshots or screencast