-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Core block styles are overriding theme.json styles in WordPress 6.6 #62679
Comments
I can concur this is happening, as the example @ndiego used came from work I was doing earlier today. I have experienced other similar cases of core block styles overriding theme.json as well, so it's not limited to what he mentioned above. |
Another example of this can be seen with css styles I have applied to Post Comments Form block in theme.json (https://github.com/bgardner/powder/blob/main/theme.json#L369) which now require the use of !important to ensure the border-color is being applied properly. For the sake of demo, here's a screenshot with the override happening after I have omitted the !Important in the inspector. The textarea should be #0a0a0a (contrast color) but it's now #949494. |
Adding priority high—these issues can erode confidence in using the toolset around block themes, so should do our outmost to address them preemptively. Where are we with regard to absorbing all cosmetic block styles in the bundled theme.json file that ships with WordPress? |
It's false that this was introduced by #61638, which merely increased the specificity of theme.json styles from 0 to 0-1-0, to fix most issues with reset and default styles. This was introduced by #60106, which reduced all theme.json styles to 0-0-0. You can test this yourself by checking the previous commit. The default style specificity was then lowered for |
@ellatrix and others... so what about instances of My two instances were: https://github.com/bgardner/powder/blob/main/theme.json#L512 Screenshots of these styles getting overridden still by core using Playground with the PR: |
Any bugs aside. Is it correct to say that styles defined in theme.json should always "beat" default block styles? |
Yes, normally they should. But there were reasons for setting the specificity of theme.json to the same level. I think @aaronrobertshaw or @tellthemachines can explain better. Maybe there's a way to mass-reduce all default styles to specificity 0-1-0. I'm not sure. And there might be other consequences. |
@bgardner Aside from the comment textarea, are there more instances? I can fix them in a PR. |
@ellatrix Yes, the social icons css is also not working (https://github.com/bgardner/powder/blob/main/theme.json#L512) and second screenshot in this comment (#62679 (comment)). |
@ellatrix Any chance the PR gets into RC 1 tomorrow? |
I created a PR for the textarea. I don't know what is causing the social links issue, more information would be helpful. |
@talldan Yes, using Playground, I just tested to see if the removal of !Important leaves the social icons styled as expected. Confirmed, and works! Possible we get this into RC2? |
Here's a great roundup of the 0,1,0 story and related links at bottom for anyone who is struggling and finds this issue/discussion: https://make.wordpress.org/core/2024/06/21/wordpress-6-6-css-specificity/ |
Description
If you have applied styles to specific elements in
theme.json
, perhaps blocks as well, there is a chance that they will be overridden by default block styles. I have not had a chance to test this issue widely, but I discovered (with the help of @bgardner) that the element styles intheme.json
for Image block captions are no longer respected in 6.6.Take a look at the screenshots below. You will see that the specificity changes in #61638 seem to have swapped the style order. This causes the block style to override
theme.json
. In my opinion,theme.json
should always "beat" default block styles.Step-by-step reproduction instructions
theme.json
, add the following to the caption elementScreenshots, screen recording, code snippet
Environment info
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
The text was updated successfully, but these errors were encountered: