Skip to content
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

Merged
merged 4 commits into from
Jun 18, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/block-library/src/navigation/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -519,9 +519,11 @@ private static function get_responsive_container_markup( $attributes, $inner_blo
';
}

$overlay_inline_styles = esc_attr( safecss_filter_attr( $colors['overlay_inline_styles'] ) );

return sprintf(
'<button aria-haspopup="dialog" %3$s class="%6$s" %10$s>%8$s</button>
<div class="%5$s" style="%7$s" id="%1$s" %11$s>
<div class="%5$s" %7$s id="%1$s" %11$s>
<div class="wp-block-navigation__responsive-close" tabindex="-1">
<div class="wp-block-navigation__responsive-dialog" %12$s>
<button %4$s class="wp-block-navigation__responsive-container-close" %13$s>%9$s</button>
Expand All @@ -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" : '',
Copy link
Contributor

@talldan talldan Jun 18, 2024

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:

Suggested change
( ! empty( $overlay_inline_styles ) ) ? "style=$overlay_inline_styles" : '',
( ! empty( $overlay_inline_styles ) ) ? "style=\"$overlay_inline_styles\"" : '',

To reproduce:

  1. Set a navigation block to Overlay - 'Always'
  2. Add some custom colors for the overlay menu
  3. Save and view the frontend - observe the custom colors aren't applied.

Copy link
Member Author

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.

$toggle_button_content,
$toggle_close_button_content,
$open_button_directives,
Expand Down
Loading