-
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
theme.json schema: Don't allow css property except at the root and block level #53156
Conversation
Flaky tests detected in 62e3e13. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5706409803
|
--- | ||
|
||
### css | ||
|
||
Sets custom CSS to apply styling not covered by other theme.json properties. | ||
|
||
|
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.
If the schema is strictly defined, the css
property will unfortunately be removed from the document. It may be possible to revive this description by slightly forcing the docs:theme-ref
logic to be adjusted.
However, now that css
properties are only allowed in certain hierarchies, I personally think it is acceptable. If in the future, css
properties will be available everywhere related to style, I think it would be fine to add them at that time.
62e3e13
to
c369508
Compare
c369508
to
2c85d09
Compare
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. |
I tested this again and it seems the css works on both Therefore, I'm closing this PR. |
Fixes #52217
What?
This PR changes the theme.json schema to not allow the insertion of CSS properties except at the root level of the
styles
property and directly understyles.blocks
.Why?
For now,
css
property are only available in the site root and block and will not work if specified on variations or elements. It would make sense to display a warning according to the schema when a CSS property is defined that does not work.How?
Removed
css
property fromstylesProperties
. This is because if this property is present, it will appear as a candidate, even if thecss
property is not allowed.Removed
css
property fromstylesElementsPropertiesComplete
andstylesPropertiesComplete
. This will trigger a warning whencss
properties are defined primarily at the element level.Instead of removing
css
fromstylesProperties
, adddescription
andtype
tocss
properties instyles
andstylesPropertiesAndElementsComplete
. This is to display a description when inserting a property and to insert a default empty string when the property is inserted.Testing Instructions
Create locally a theme.json with the schema directed to this PR:
theme.json sample
Use this theme.json file to confirm the following:
"css"
understyles
andstyles.blocks.{blockname}
, a property with a description should appear in the candidate list. If you add a definition, you should not get a warning."css"
anywhere else, it should not appear as a candidate. If you defined the property manually, you should get a warning.