-
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
Fix opinionated block styles loading in editor. #40937
Conversation
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.
This is working well for me following the test instructions. I can see that theme.css is not loaded in the editor unless the theme has opted into wp-block-styles
.
if ( current_theme_supports( 'wp-block-styles' ) ) { | ||
$style_handles[] = 'wp-block-library-theme'; | ||
} | ||
|
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.
How is this related to the similar code in gutenberg_edit_site_init
if (
current_theme_supports( 'wp-block-styles' ) ||
( ! is_array( $editor_styles ) || count( $editor_styles ) === 0 )
) {
wp_enqueue_style( 'wp-block-library-theme' );
}
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.
I am not sure, but I did try changing those conditions (removing the enqueue) and it did not affect whether the theme.css was loaded in the site editor.
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.
I think its duplicated because this is a compat file, but it introduces this bug into 6.0. IMO this fix should be backported to 6.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.
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.
Added to the 6.0 board in the Triage column. @ndiego will take care of everything else as usual. Thank you.
I am struggling to replicate the original issue. I am using Gutenberg 13.1 and 6.0 RC1. I have also tested with just RC1. With |
Correct |
@scruffian, but my testing above was without this PR applied. |
Did you test in the Site Editor, not the Post Editor? That's the only environment where I see the issue. |
🤦♂️ My apologies, I was looking in the Post Editor. Yes, I can replicate it in the Site Editor and this PR fixes the issue. |
34013cb
to
742d632
Compare
Thanks everyone for the reviews and @scruffian for the rebase. |
* Fix theme styles dependency load. * Use preferrend handle. * Fix linting bug.
I went ahead and cherry-picked this PR to the wp/6.0 branch to get it included in the next release: b994942 |
This change has to be applied manually in WordPress core. |
Related changes in Gutenberg: WordPress/gutenberg#40937. Backport for WordPress 6.0 RC 4. Props jffng. See #55567. git-svn-id: https://develop.svn.wordpress.org/trunk@53419 602fd350-edb4-49c9-b593-d223f7449a82
Committed to WP Core with WordPress/wordpress-develop@af8844c. |
Related changes in Gutenberg: WordPress/gutenberg#40937. Backport for WordPress 6.0 RC 4. Props jffng. See #55567. Built from https://develop.svn.wordpress.org/trunk@53419 git-svn-id: http://core.svn.wordpress.org/trunk@53008 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Related changes in Gutenberg: WordPress/gutenberg#40937. Backport for WordPress 6.0 RC 4. Props jffng. See #55567. Built from https://develop.svn.wordpress.org/trunk@53419 git-svn-id: https://core.svn.wordpress.org/trunk@53008 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Related changes in Gutenberg: WordPress/gutenberg#40937. Backport for WordPress 6.0 RC 4. Props jffng. See #55567. Built from https://develop.svn.wordpress.org/trunk@53419
What?
This PR checks if the current theme has declared support for
wp-block-styles
before adding the dependency in the site editor.Why?
Right now the opinionated styles are being loaded in the editor, regardless if the theme has declared support.
How?
I traced the problem to the 6.0 compat file.
Testing Instructions
emptytheme
add_theme_support( 'wp-block-styles' );
line of the theme's functions.phpScreenshots or screencast
cc @WordPress/block-themers