-
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
Global Styles: Fix retrieval of referenced preset values in editor #59811
Global Styles: Fix retrieval of referenced preset values in editor #59811
Conversation
I'm open to suggestions if there is a better place to resolve retrieved |
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. |
Size Change: +1 B (0%) Total Size: 1.71 MB
ℹ️ View Unchanged
|
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.
Thanks for the quick fix!
I tested using the following theme json:
{
"$schema": "https://schemas.wp.org/trunk/theme.json",
"version": 2,
"settings": {
"appearanceTools": true,
"typography": {
"fontSizes": [
{
"name": "Small",
"slug": "small",
"size": "13px"
},
{
"name": "Med",
"slug": "med",
"size": "25px"
}
]
}
},
"styles": {
"blocks":{
"core/heading": {
"typography": {
"fontSize": {
"ref": "styles.elements.h1.typography.fontSize"
}
}
}
}
}
}
Then follow the steps in the original issue: #59585
The var is being parsed correctly 👍🏻 custom font sizes aren't affected either
Before | After |
---|---|
![]() |
![]() |
Fixes: #59585
What?
Updates the retrieval of values for styles set using
ref
within theme.json to resolve thevar:preset|<type>|<value>
preset strings intovar(--wp--preset--type--value)
CSS values.Why?
Without this fix, invalid CSS is generated within the editor for styles that
ref
another preset value within global styles.How?
Pass the referenced value through
compileStyleValue
as happens with non-referenced values.Testing Instructions
Ensure new unit test passes:
npm run test:unit packages/block-editor/src/components/global-styles/test/use-global-styles-output.js
The easiest means of testing this manually is via the contrived scenario below:
core/heading
block's styles to use aref
value for itsfontSize
(see snippet below)core/heading
block again and confirm its font size rule has a valid CSS value e.g.var(--wp--preset--font-size--xx-large)
Screenshots or screencast