-
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: Custom Color names with numbers at the end are not reflected #55587
Comments
The same thing happened to me. |
I tested this issue by attending a "Contribution to Gutenberg" event in Japan. This problem reproduces in my environment and I suspect the function:
|
Additional information. When creating a custom color, The value is saved in the At that time, the following payload is sent (excerpt):
In other words, the "slug" value before applying the kebab case is stored in the database. This may be solved by applying the kebab case when outputting this "slug" value on the editing screen. |
I was looking into this issue, and I think the fundamental problem is that the kebabCase logic is not unified. In the Global Styles, when you rename a custom color palette, the slug is generated here:
This Then, when you apply this color to the site background and save the entity, the following content will be saved in the database: {
"styles": {
"color": {
"background": "var:preset|color|custom-my-color1"
}
},
"settings": {
"color": {
"palette": {
"custom": [
{
"color": "#000",
"name": "MyColor1",
"slug": "custom-my-color1"
}
]
}
}
},
"isGlobalStylesUserThemeJSON": true,
"version": 2
} Based on this styles property data, the following styles are generated to the body element on the front end: body {
background-color: var(--wp--preset--color--custom-my-color1);
} The CSS variable that is the source of this value is generated based on the data in the settings property, and is processed by gutenberg/lib/class-wp-theme-json-gutenberg.php Line 1815 in 16eb009
Since the body {
--wp--preset--color--custom-my-color-1: #000;
} The style is not applied because the generated CSS variable name and the CSS variable name that is actually applied as the value do not match. I think the rules for kebabCase probably need to be unified, but I'll look into it a little more. |
Description
When you add the custom colors, that name has a number at the end on Global Styles. You can add the color, select the site's colors, and save. But the color doesn't reflect the site.
The auto-generated CSS variable name for the colors and the CSS variable name that is assigned to an element seems different. It is caused by the presence or absence of hyphens.
related: #53695
Step-by-step reproduction instructions
Screenshots, screen recording, code snippet
Kapture.2023-10-25.at.09.41.35.mp4
Environment info
It reproduces whether Gutenberg is enabled or not.
WordPress: 6.4 RC2
Browser: Chrome 117.0.5938.149
OS: Mac OS 12.5.1
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: