From 59286b182d494f2df44df0c2e42e5aae3c341671 Mon Sep 17 00:00:00 2001 From: Utsav Patel Date: Sat, 15 Jun 2024 23:45:49 +0530 Subject: [PATCH 1/4] Fix: empty style attribute issue in navigation block --- packages/block-library/src/navigation/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/block-library/src/navigation/index.php b/packages/block-library/src/navigation/index.php index f814e19a13cd3..debaa7570c685 100644 --- a/packages/block-library/src/navigation/index.php +++ b/packages/block-library/src/navigation/index.php @@ -521,7 +521,7 @@ private static function get_responsive_container_markup( $attributes, $inner_blo return sprintf( ' -
+
@@ -537,7 +537,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( esc_attr( safecss_filter_attr( $colors['overlay_inline_styles'] ) ) ) ) ? ( 'style="' . esc_attr( safecss_filter_attr( $colors['overlay_inline_styles'] ) ) . '"' ) : '', $toggle_button_content, $toggle_close_button_content, $open_button_directives, From e34a16bd7a4d3905d477f54857bc528fc96a45f6 Mon Sep 17 00:00:00 2001 From: Utsav Patel Date: Mon, 17 Jun 2024 12:47:48 +0530 Subject: [PATCH 2/4] update: store overlay style to variable for better readibility and performance --- packages/block-library/src/navigation/index.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/block-library/src/navigation/index.php b/packages/block-library/src/navigation/index.php index debaa7570c685..ecb7b551c74d8 100644 --- a/packages/block-library/src/navigation/index.php +++ b/packages/block-library/src/navigation/index.php @@ -519,6 +519,8 @@ private static function get_responsive_container_markup( $attributes, $inner_blo '; } + $overlay_inline_styles = esc_attr( safecss_filter_attr( $colors['overlay_inline_styles'] ) ); + return sprintf( '
@@ -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 ) ), - ( ! empty( esc_attr( safecss_filter_attr( $colors['overlay_inline_styles'] ) ) ) ) ? ( 'style="' . esc_attr( safecss_filter_attr( $colors['overlay_inline_styles'] ) ) . '"' ) : '', + ( ! empty( $overlay_inline_styles ) ) ? "style=$overlay_inline_styles" : '', $toggle_button_content, $toggle_close_button_content, $open_button_directives, From a0d60e965fa7a18c3aee7f61fa9bf8fbd88654bd Mon Sep 17 00:00:00 2001 From: Utsav Patel Date: Mon, 17 Jun 2024 12:57:46 +0530 Subject: [PATCH 3/4] Fix: linting issue --- packages/block-library/src/navigation/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/block-library/src/navigation/index.php b/packages/block-library/src/navigation/index.php index ecb7b551c74d8..ca227fcaac856 100644 --- a/packages/block-library/src/navigation/index.php +++ b/packages/block-library/src/navigation/index.php @@ -519,7 +519,7 @@ private static function get_responsive_container_markup( $attributes, $inner_blo '; } - $overlay_inline_styles = esc_attr( safecss_filter_attr( $colors['overlay_inline_styles'] ) ); + $overlay_inline_styles = esc_attr( safecss_filter_attr( $colors['overlay_inline_styles'] ) ); return sprintf( ' From 791f3a3a6b6e3b374451cbd23658a0aba589e239 Mon Sep 17 00:00:00 2001 From: Utsav Patel Date: Tue, 18 Jun 2024 10:50:18 +0530 Subject: [PATCH 4/4] Fix: added missing quotes to make valid markup --- packages/block-library/src/navigation/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/block-library/src/navigation/index.php b/packages/block-library/src/navigation/index.php index ca227fcaac856..44c4d1410f4be 100644 --- a/packages/block-library/src/navigation/index.php +++ b/packages/block-library/src/navigation/index.php @@ -539,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 ) ), - ( ! empty( $overlay_inline_styles ) ) ? "style=$overlay_inline_styles" : '', + ( ! empty( $overlay_inline_styles ) ) ? "style=\"$overlay_inline_styles\"" : '', $toggle_button_content, $toggle_close_button_content, $open_button_directives,