Editor: Fix instance element styles for links applying to buttons.

These changes fix the selector used by block instance element styles for links so they do not get incorrectly applied to buttons.

Props aaronrobertshaw, freewebmentor, mukesh27.
Fixes #60557.

git-svn-id: https://develop.svn.wordpress.org/trunk@57664 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Riad Benguella 2024-02-20 11:20:22 +00:00
parent c84cddb432
commit 5f37cb1fc7
2 changed files with 5 additions and 4 deletions

View File

@ -166,8 +166,8 @@ function wp_render_elements_support_styles( $pre_render, $block ) {
'skip' => $skip_button_color_serialization,
),
'link' => array(
'selector' => ".$class_name a",
'hover_selector' => ".$class_name a:hover",
'selector' => ".$class_name a:where(:not(.wp-element-button))",
'hover_selector' => ".$class_name a:where(:not(.wp-element-button)):hover",
'skip' => $skip_link_color_serialization,
),
'heading' => array(

View File

@ -22,6 +22,7 @@ class Tests_Block_Supports_WpRenderElementsSupportStyles extends WP_UnitTestCase
* Tests that elements block support generates appropriate styles.
*
* @ticket 59555
* @ticket 60557
*
* @covers ::wp_render_elements_support_styles
*
@ -139,8 +140,8 @@ class Tests_Block_Supports_WpRenderElementsSupportStyles extends WP_UnitTestCase
),
),
),
'expected_styles' => '/^.wp-elements-[a-f0-9]{32} a' . $color_css_rules .
'.wp-elements-[a-f0-9]{32} a:hover' . $color_css_rules . '$/',
'expected_styles' => '/^.wp-elements-[a-f0-9]{32} a:where\(:not\(.wp-element-button\)\)' . $color_css_rules .
'.wp-elements-[a-f0-9]{32} a:where\(:not\(.wp-element-button\)\):hover' . $color_css_rules . '$/',
),
'generic heading element styles are applied' => array(
'color_settings' => array( 'heading' => true ),