-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Global Styles: Fix handling of booleans when stabilizing block supports #67552
Global Styles: Fix handling of booleans when stabilizing block supports #67552
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 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. |
efbbc5e
to
92e48c3
Compare
Flaky tests detected in 92e48c3. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/12155128978
|
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 the follow up!
To test I updated the group block's border support to stable, e.g.,
"border": {
...
},
Then added a filter that sets __experimentalBorder
to false
:
function disable_group_borders( $args ) {
if ( 'core/group' === $args['name'] ) {
_wp_array_set( $args, array( 'supports', '__experimentalBorder' ), false );
}
return $args;
}
add_filter( 'register_block_type_args', 'disable_group_borders', 20 );
In trunk I get the fatal error:
Fatal error: Uncaught TypeError: array_merge(): Argument #2 must be of type array, bool given in /var/www/html/wp-content/plugins/gutenberg/lib/compat/wordpress-6.8/blocks.php:128
In this PR, the border support is disabled as expected.
One thing I noticed while testing is that setting border supports to function disable_group_borders( $args ) {
if ( 'core/group' === $args['name'] ) {
_wp_array_set( $args, array( 'supports', '__experimentalBorder' ), true ); // or stable 'border' as well.
}
return $args;
}
add_filter( 'register_block_type_args', 'disable_group_borders', 20 ); Is that expected? This is the state in trunk too, so nothing to fix in this PR as far as I'm aware. |
I've tracked this down to a regression introduced when the border panel was combined for the block inspector and global styles #48636. The combined border panel assumed it only had to check the So the good news is that the recent block support stabilization didn't break it. The bad news is we broke that a long time ago! I'll get this PR merged and spin up something fresh to fix that regression. I have a suspicion the merging of panels for all the other block supports, e.g. typography, will have broken the same thing 😅 |
92e48c3
to
deb49a2
Compare
Thanks for taking the time to investigate. And excellent detective work.
If you have time, thanks! Let me know if I can help. |
Thanks @ramonjd, might need it! To make all the block supports consistent is looking like a bigger job than I hoped.
This gets murkier though when we look at the theme.json schema, particularly given how this schema has been regularly out of date and doesn't contain experimental supports e.g. border.
I had a quick look and didn't spot any submitted issues around using boolean values to toggle on all features for block supports. It might not be something that is currently leaned on by extenders. They might have also just been forced into object-based configs because of bugs 🤷 @youknowriad If you have a moment, it'd be great to tap your wisdom on what the desired outcome here should be. Do we want to support boolean opt-in/out of block support features or should we remove the fragments of that support that remain? If there's no obvious answer, I can spin up a dedicated issue for broader discussion. |
I think it's a nice little touch, but yeah maybe a hard sell for "color" because of the backwards compatibility unless we do an apiV4 at some point. |
For the supports that never worked that way, I suppose we can categorize it as a logical inconsistency and not a blocker for anything. I really appreciate the investigation and reporting here! We could also be techocratic about it and say, even though Dimensions, Borders and Spacing regressed more than a year ago, there was nothing in the spec to say they should have worked that way. Given the time span since the "regression" and today, and the lack of complaints I think it'd be possible re-introduce as an enhancement in a non-urgent fashion. At least, that's my take away. You did all the hard work 😅 - what you think? |
Related:
What?
Fixes issue introduced by #67018 resulting in mishandling of boolean config values for experimental block supports that are being stabilized e.g.
__experimentalBorder
.This problem was raised on the backport PR for block support stabilization.
Why?
Without a fix, this bug will throw a fatal error when experimental block supports with boolean config values are stabilized.
How?
Testing Instructions
register_block_type_args
filter that replaces thesupports.__experimentalBorder
config with a boolean true or falseborder
key that uses a boolean value.