-
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: Add block CSS rules after the Global Styles rules #41934
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.
Makes perfect sense and the code is clean, simply adding a dependency to the stylesheets 👍
This is solving the original issue for me, but now other blocks are more specific than the elements rules in theme.json. In my testing, the search block rules in packages/block-library/src/search/style.scss are applying before the ones in theme.json |
Size Change: -68 B (0%) Total Size: 1.25 MB
ℹ️ View Unchanged
|
Thanks @MaggieCabrera, those two points should now be addressed... |
Hey, the result of this PR is that the block CSS overrides theme and user preferences, breaking the whole styles algorithm. I've been out for a while and may be missing things, but with the info I have today I suggest we revert this change. Can we explore a path like #34180 to solve the issues of the button block? |
I see that we reverted these changes back at #43022 |
What?
This changes the load order of CSS for blocks to make it dependent on Global Styles. This means that the block CSS will load after Global Styles
Fixes #41918
Why?
Now that the block CSS also contains user's settings, it's necessary to load it after the Global Styles CSS, since these rules are meant to take priority.
How?
wp_register_style
takes a dependencies array as an argument, which determines load order. By settingglobal-styles
as the dependency, we ensure that block CSS loads later than the main Global Styles stylesheet.The problem is that moving these styles later means that they now override button element styles. To overcome this:
Testing Instructions
Using the Remote theme, add a buttons block to your post. The buttons should be yellow, not grey.
Other things to test:
Screenshots or screencast
See #41918
Note
This will probably break other things - if there are rules set in block CSS and then overridden in Global Styles for example...
Also, before we merge this we'll need to copy this function to the compat folder.
@WordPress/block-themers