-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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: Correctly decode border color values #57876
Conversation
Size Change: -35 B (0%) Total Size: 1.69 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.
Not sure when this bug crept in but it looks like it could have been around the time the panels were unified between the editors. Thanks for digging into it and creating the fix @t-hamano 👍
✅ Can replicate the issue on trunk
✅ Issue is resolved on this PR
✅ Works on in both editors and frontend
✅ Works for unified or split borders
LGTM 🚢
Thanks for the review @aaronrobertshaw! |
Fixes #52733
What?
This PR fixes an issue where border color checkmarks are missing in the Global Styles.
87831ece04106b09c02fab99ce21b73c.mp4
Why?
With the current logic, the border color is decoded as follows:
decodeColorValue()
functiondecodeColorValue()
function, find the color that matches the format'var:preset|color|' + slug
among all colors.However, when the Global Style is saved after the palette is selected, the color value is converted to a format called
var(--wp--preset--color--{slug})
.This format no longer matches the
'var:preset|color|' + slug
format, so the color cannot be found and converted to the actual color value. As a result, the color popover recognizes it as a custom color and does not check the original palette.How?
Instead of the
decodeColorValue()
function, simply use thedecodeValue()
function.My understanding is that when decoding a color, there is no need to consider whether the current color exists in color palettes. We should simply convert the color slug to the corresponding color value via
decodeValue()
.Testing Instructions
Screenshots or screencast
a549e25533b54973b15e1d14039dee4f.mp4