Global Styles: Fix retrieval of referenced preset values in editor#59811
Global Styles: Fix retrieval of referenced preset values in editor#59811aaronrobertshaw merged 2 commits intotrunkfrom
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
|
ramonjd
left a comment
There was a problem hiding this comment.
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
refwithin 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
refanother preset value within global styles.How?
Pass the referenced value through
compileStyleValueas 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.jsThe easiest means of testing this manually is via the contrived scenario below:
core/headingblock's styles to use arefvalue for itsfontSize(see snippet below)core/headingblock again and confirm its font size rule has a valid CSS value e.g.var(--wp--preset--font-size--xx-large)Screenshots or screencast