-
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
Change location of block support styles in <head>
#39164
Change location of block support styles in <head>
#39164
Conversation
Just a quick note for those reviewing. While this PR places the styles in the correct spot in |
@c4rl0sbr4v0 I was just doing some more testing and discovered other issues that this PR fixes. Without this fix, block styles override This can be tested using Twenty Twenty-Two:
Note that it still looks ok in the Editor because the styles are still loaded in the footer. |
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.
@ndiego Is there no option to maybe use $deps?
https://developer.wordpress.org/reference/functions/wp_enqueue_script/
https://developer.wordpress.org/reference/functions/wp_enqueue_style/
E.g. Must have XYZ included? I am not really understanding what the issue is so I am probably not the right person to be reviewing this.
Thanks for taking a look @alexstine. The issue is not about what is be loaded, more about where. All of these styles need to get added, just after all the inline block/global styles. In Gutenberg 12.6, the block support styles were loaded in the footer. #38750 fixed this by placing them in the |
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.
Left another idea after checking the code.
@@ -63,7 +63,7 @@ function gutenberg_enqueue_global_styles_assets() { | |||
function gutenberg_enqueue_block_support_styles( $style ) { | |||
$action_hook_name = 'wp_footer'; | |||
if ( wp_is_block_theme() ) { | |||
$action_hook_name = 'wp_enqueue_scripts'; |
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.
@ndiego Why not add:
$action_hook_priority = 999;
Then the block support styles can load after the global styles as default priority on hooks is 10. If you are looking to do the reverse, you can make the priority 9 or lower as it will load before the priority of 10. Does this make sense?
@MaggieCabrera pinging you here to see if this fix resolves the issues you were having in #39014. I believe it does but would love your review if you have time. |
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.
The PR brings back visual consistency between 12.6 and 12.7. I tested and everything seems fine. We will still need to work on styles cascade :-)
Looks good to me!
Did the original PR made it to the WP minor @oandregal @jorgefilipecosta ? wondering whether we should flag this for potential next minor. |
Thanks for bringing this in! +1 to flagging this for next minor |
Backports changes from WordPress/gutenberg#39164. Props ndiego, alexstine, cbravobernal, mamaduka. See #55474. git-svn-id: https://develop.svn.wordpress.org/trunk@53015 602fd350-edb4-49c9-b593-d223f7449a82
Backports changes from WordPress/gutenberg#39164. Props ndiego, alexstine, cbravobernal, mamaduka. See #55474. Built from https://develop.svn.wordpress.org/trunk@53015 git-svn-id: http://core.svn.wordpress.org/trunk@52604 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Backports changes from WordPress/gutenberg#39164. Props ndiego, alexstine, cbravobernal, mamaduka. See #55474. Built from https://develop.svn.wordpress.org/trunk@53015 git-svn-id: https://core.svn.wordpress.org/trunk@52604 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Backports changes from WordPress/gutenberg#39164. Props ndiego, alexstine, cbravobernal, mamaduka. Merges [53015] to the 5.9 branch. See #55474. git-svn-id: https://develop.svn.wordpress.org/branches/5.9@53017 602fd350-edb4-49c9-b593-d223f7449a82
Backports changes from WordPress/gutenberg#39164. Props ndiego, alexstine, cbravobernal, mamaduka. Merges [53015] to the 5.9 branch. See #55474. Built from https://develop.svn.wordpress.org/branches/5.9@53017 git-svn-id: http://core.svn.wordpress.org/branches/5.9@52606 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Backports changes from WordPress/gutenberg#39164. Props ndiego, alexstine, cbravobernal, mamaduka. Merges [53015] to the 5.9 branch. See #55474. Built from https://develop.svn.wordpress.org/branches/5.9@53017 git-svn-id: https://core.svn.wordpress.org/branches/5.9@52606 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Backports changes from WordPress/gutenberg#39164. Props ndiego, alexstine, cbravobernal, mamaduka. Merges [53015] to the 5.9 branch. See #55474. Built from https://develop.svn.wordpress.org/branches/5.9@53017
Backports changes from WordPress/gutenberg#39164. Props ndiego, alexstine, cbravobernal, mamaduka. Merges [53015] to the 5.9 branch. See #55474. Built from https://develop.svn.wordpress.org/branches/5.9@53017 git-svn-id: http://core.svn.wordpress.org/branches/5.9@52606 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Description
#38750 moved to block support styles to
<head>
, which was great. However these styles were loaded before block/global inline styles. This causes block support styles (which includes user styles set in the Editor) to be potentially overwritten by block/global inline styles.In this PR, instead of using
wp_enqueue_scripts
, we usewp_head
instead. This ensures that block support styles are loaded after the block/global inline styles in<head>
.There may be a better option than
wp_head
, but I have so far not been able to find one that works. Any insight would be greatly appreciated!Screenshots
Here are some screenshots looking at the Site Title block. In theme.json, there is a link color applied. Before this change, this color overrides the custom orange color set by the user in the Editor. After the change, the user color takes precedent.
Before:
After:
Types of changes
Checklist:
*.native.js
files for terms that need renaming or removal).