-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
add support for __experimentalSkiSerialization to the shadow attribute #6279
add support for __experimentalSkiSerialization to the shadow attribute #6279
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 Core Committers: Use this line as a base for the props when committing in SVN:
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
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.
Thanks for backporting this fix @colinduwe 👍
The change here matches WordPress/gutenberg#59887.
I was going to note that we should add a unit test for this but it appears no tests have been added for the shadow block support like there are for typography, border etc.
@madhusudhand are you aware of any PRs in progress adding unit tests for the shadow support?
While this does allow support for an experimental block.json property (that should be stabilized soon), it does make the shadow block support consistent with all others while only introducing a call to a stable core function. I'd like to see this land.
I have created WordPress/gutenberg#60063 which tests these changes. |
👋 @colinduwe @madhusudhand what is the status here? It looks like WordPress/gutenberg#60063 has been approved. Are you facing any blockers? |
@vcanales I think it is probably only blocked by my ignorance of the process here. I thought this was merely awaiting approval from someone with commit access. |
Once WordPress/gutenberg#60063 is merged, this should probably also include the unit test the code change relates to. |
@colinduwe could you bring the unit tests from WordPress/gutenberg#60063 into this? |
@madhusudhand I think I'm out of my depth here. I'm not sure how to do that. |
@colinduwe I have created #6613 with the unit tests.
|
Your're a hero @madhusudhand. Thanks. Done. |
public function test_gutenberg_apply_shadow_support( $support, $value, $expected ) { | ||
$block_type = self::register_shadow_block_with_support( | ||
'test/shadow-block', | ||
array( 'shadow' => $support ) | ||
); | ||
$block_attrs = array( 'style' => array( 'shadow' => $value ) ); | ||
$actual = gutenberg_apply_shadow_support( $block_type, $block_attrs ); |
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.
Thanks for bringing in the tests!
We have to rename the functions, since the gutenberg_
prefix is meant to be used within Gutenberg and not core (https://github.com/WordPress/wordpress-develop/pull/6279/files#diff-a903d994435db8240aed96e253cfb2097ecbe9705d6f88ecdfd441422ecf2da3R52)
public function test_gutenberg_apply_shadow_support( $support, $value, $expected ) { | |
$block_type = self::register_shadow_block_with_support( | |
'test/shadow-block', | |
array( 'shadow' => $support ) | |
); | |
$block_attrs = array( 'style' => array( 'shadow' => $value ) ); | |
$actual = gutenberg_apply_shadow_support( $block_type, $block_attrs ); | |
public function test_wp_apply_shadow_support( $support, $value, $expected ) { | |
$block_type = self::register_shadow_block_with_support( | |
'test/shadow-block', | |
array( 'shadow' => $support ) | |
); | |
$block_attrs = array( 'style' => array( 'shadow' => $value ) ); | |
$actual = wp_apply_shadow_support( $block_type, $block_attrs ); |
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.
Fixed here.
@colinduwe please pull and
git cherry-pick 5383012d66abb19d39388750fd3e1b46ec0d60b6
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.
Done
@@ -52,7 +52,10 @@ function wp_register_shadow_support( $block_type ) { | |||
function wp_apply_shadow_support( $block_type, $block_attributes ) { | |||
$has_shadow_support = block_has_support( $block_type, 'shadow', false ); | |||
|
|||
if ( ! $has_shadow_support ) { | |||
if ( |
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.
Would be good to add a since
note to the docblock above; something like
@since 6.6.0 Return early if __experimentalSkipSerialization is true.
(it should be added just below @since 6.3.0
)
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.
Thanks for updating @colinduwe, LGTM!
Committed in r58312. |
* @param string $value Shadow style value for style attribute object. | ||
* @param array $expected Expected shadow block support styles. | ||
*/ | ||
public function test_wp_apply_shadow_support( $support, $value, $expected ) { |
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.
@tellthemachines why the ticket number is not mention for test?
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.
Thanks for spotting that! Fixed in https://core.trac.wordpress.org/changeset/58315.
What?
This is a backport of the merged Gutenberg PR WordPress/gutenberg#59887
When a dynamic block defines __experimentalSkipSerialization in its block.supports.shadow the styles continue to be printed to the block wrapper element. This PR corrects that behavior so that shadow behaves like border, color, and others.
Why?
This provides the expected behavior for dynamic blocks that need to opt out of having the shadow styles printed to the block wrapper.
How?
Added a check at the start of the render function to return an empty array if the block has set __experimentalSkipSerialization
(This is my first attempt at submitting a Gutenberg PR to be included back into WP Core so welcome any advice if I'm doing this wrong)
Trac ticket: https://core.trac.wordpress.org/ticket/60784#ticket
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.