-
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
Font-size values (normal & huge) defined in theme.json conflict with default editor styles #59701
Comments
Thanks for filing this issue. Has this bug been fixed already? 🤔 I tested in Gutenberg trunk, and also WordPress 6.5-beta3-57723-src without any plugins installed, and couldn't reproduce. 2024-03-08.10.29.00.mp4 |
Hey @ramonjd , thanks for your quick reply. In your video, I think you're using block styles. The below gif displays how these font sizes get displayed in the editor sidebar. The main issue here, as far as I see, is that this overwrite breaks the fluid typography feature enabled in the I used a hotfix in the editor stylesheet, overwriting the style pushed by the default editor style with the font size values used in
The hotfix looks like this: .editor-styles-wrapper,
:root {
--wp--preset--font-size--normal: 1rem;
--wp--preset--font-size--huge: 1.777rem;
@media ( max-width: 768px ) {
--wp--preset--font-size--normal: .888rem;
--wp--preset--font-size--huge: 1.333rem;
}
@media ( min-width: 1601px ) {
--wp--preset--font-size--normal: 1rem;
--wp--preset--font-size--huge: 1.7777rem;
}
} A permanent fix would be providing a way to disable specific default editor styles, like the one reported here. |
Oh sorry, I forgot to mention I was using the theme.json font size presets mentioned in this issue's description, and was just applying those sizes at the block level yes. May I ask, have you tried testing in WordPress 6.5 beta or with the latest Gutenberg version? I only ask because the issue cites
But there was a pretty major bug fix that was merged since 6.4, that might be related: |
Hey @ramonjd , Thanks - I'm totally overwhelmed with a theme project now, but I'll reply as soon as I have some spare time, on 18th Monday at the latest. |
I can confirm that this has been fixed in 6.5. The font size in theme.json is used, even when it matches an existing CSS variable. Normal and huge are legacy font sizes that used to be part of the default preset, but were renamed. They are output in the editor and front for backward compatibility. |
Thanks for confirming @carolinan I'll close this issue as fixed. @lunule if you can still reproduce in WordPress 6.5 or with the latest Gutenberg version, please feel free to reopen. 👍🏻 |
Possible regression. The |
I was also able to reproduce this problem with the latest Gutenberg. I used the theme.json below and tested it in the site editor. theme.json{
"version": 2,
"settings": {
"typography": {
"fluid": true,
"fontSizes": [
{
"fluid": {
"min": ".888rem",
"max": "1rem"
},
"name": "Normal",
"size": "1rem",
"slug": "normal"
},
{
"fluid": {
"min": "1.333rem",
"max": "1.777rem"
},
"name": "Huge",
"size": "3rem",
"slug": "huge"
}
]
}
}
} WP6.5 RC4The Latest GutenbergIn the latest version of Gutenberg, this style relationship is reversed. |
It's because of this change: I'm not sure what to do here. The
But they conflict with a progressive change, that is, using Also, Since Gutenberg only supports the last 2 versions of WordPress, should we consider deleting these styles as a solution to this issue? |
I think these styles are meant to support older WordPress versions that don't use Gutenberg, so I'm concerned that these styles can't be removed. However, on the editor side, these styles seem to exist in duplicate:
I'm not that knowledgeable, but I think it might be possible to delete these styles defined in A similar issue has been reported in #56293, but @oandregal mentions this issue in detail in this comment, so maybe he knows something about it 🙏 |
In this case, wouldn't it be a workable strategy to inject these rules in a version-dependent way, e.g. for versions below v6.4 or similar? Even better, it would be great if
... where, as we're talking about a feature that exists solely for backwards compatibility, the default state of the "switch" would be off (rules not added to any of the predefined stylesheets) - then theme authors developing with backwards compatibility in mind could simply enable the feature. (Basically, my main main concern with this issue is the forced nature of the inclusion of CSS presets with preset names that'll most probably be used by theme authors in the development process.) |
I agree, this is regrettable, but I think I might have found a couple of workable alternatives:
I've tested number 1, as the second seems inherently sketchy: |
Its a good question. I'm not sure. Backwards compatibility is an important consideration for any WordPress change, but there's no one way of maintaining (and breaking) it. It's probably a naive idea, but I think it would be nice to put all backwards compat fixes in a little box, e.g., a hook to allow folks to disable some or all of them completely on their sites. Nevertheless, there are other, less technical paths, such as education and communication:
https://developer.wordpress.org/block-editor/contributors/code/backward-compatibility/ It's hard to judge when backwards compatibility is no longer possible or sustainable. Maybe in a few years we'll come back to this issue and decide 2028 is the time to delete the styles 😆 |
Number 1 broke too many things. The sketchy one seems to work and has a lighter footprint: |
I looked into this issue by looking at what priority CSS variables have in each WordPress version. This problem occurred in WP6.4 and was resolved once in WP6.5. However, the issue has been reproduced in the latest Gutenberg. The following shows how a CSS variable with a slug of WP6.3.4✅ Non-iframed Post Editor/* Inline style */
.editor-styles-wrapper {
--wp--preset--font-size--huge: clamp(2rem, 2rem +((1vw - 0.48rem)* 1.923), 3rem);
}
.editor-styles-wrapper {
--wp--preset--font-size--huge: 42px;
}
body {
--wp--preset--font-size--huge: clamp(2rem, 2rem +((1vw - 0.48rem)* 1.923), 3rem);
}
:root {
--wp--preset--font-size--huge: 42px;
} ✅ Iframed Post Editor and Site Editor/* Inline style */
.editor-styles-wrapper {
--wp--preset--font-size--huge: clamp(2rem, 2rem +((1vw - 0.48rem)* 1.923), 3rem);
}
/* editor.min.css */
.editor-styles-wrapper {
--wp--preset--font-size--huge: 42px;
}
/* style.min.css */
:root {
--wp--preset--font-size--huge: 42px;
} WP6.4.4✅ Non-iframed Post Editor/* Inline style */
.editor-styles-wrapper {
--wp--preset--font-size--huge: clamp(2rem, 2rem +((1vw - 0.48rem)* 1.923), 3rem);
}
.editor-styles-wrapper {
--wp--preset--font-size--huge: 42px;
}
body {
--wp--preset--font-size--huge: clamp(2rem, 2rem +((1vw - 0.48rem)* 1.923), 3rem);
}
:root {
--wp--preset--font-size--huge: 42px;
} ❌ Iframed Post Editor and Site Editor/* editor.min.css */
.editor-styles-wrapper {
--wp--preset--font-size--huge: 42px;
}
/* Inline style */
body {
--wp--preset--font-size--huge: clamp(2rem, 2rem +((1vw - 0.48rem)* 1.923), 3rem);
}
/* style.min.css */
:root {
--wp--preset--font-size--huge: 42px;
} WP6.5.2✅ Non-iframed Post Editor/* Inline style */
.editor-styles-wrapper {
--wp--preset--font-size--huge: clamp(2rem, 2rem +((1vw - 0.48rem)* 1.923), 3rem);
}
:where(.editor-styles-wrapper) {
--wp--preset--font-size--huge: 42px;
}
body {
--wp--preset--font-size--huge: clamp(2rem, 2rem +((1vw - 0.48rem)* 1.923), 3rem);
}
:root {
--wp--preset--font-size--huge: 42px;
} ✅ Iframed Post Editor and Site Editor/* Inline style */
body {
--wp--preset--font-size--huge: clamp(2rem, 2rem +((1vw - 0.48rem)* 1.923), 3rem);
}
/* editor.min.css */
:where(.editor-styles-wrapper) {
--wp--preset--font-size--huge: 42px;
}
/* style.min.css */
:root {
--wp--preset--font-size--huge: 42px;
} Latest Gutenberg plugin❌ Iframed Post Editor and Site Editor/* editor.css */
:where(.editor-styles-wrapper) {
--wp--preset--font-size--huge: 42px;
}
/* Inline style */
:root {
--wp--preset--font-size--huge: clamp(2rem, 2rem +((1vw - 0.48rem)* 1.923), 3rem);
}
/* style.css */
:root {
--wp--preset--font-size--huge: 42px;
} ✅ Non-iframed Post Editor/* Inline style */
.editor-styles-wrapper {
--wp--preset--font-size--huge: clamp(2rem, 2rem +((1vw - 0.48rem)* 1.923), 3rem);
}
/* editor.css */
:where(.editor-styles-wrapper) {
--wp--preset--font-size--huge: 42px;
}
:root {
--wp--preset--font-size--huge: clamp(2rem, 2rem +((1vw - 0.48rem)* 1.923), 3rem);
}
/* style.css */
:root {
--wp--preset--font-size--huge: 42px;
} It's difficult to find out the root cause due to the complicated history, but I would like to test if #60400 solves this problem. |
Fixed by #60400 |
Description
If you're using font sizes in theme.json with the slugs
normal
and/orhuge
, the specified values get overwritten in the admin by default editor styles.A setup in theme.json like this don't work in the admin:
... because the following default editor styles overwrite the correct settings:
Step-by-step reproduction instructions
normal
andhuge
, withsize
values any other than the following:16px
fornormal
42px
forhuge
huge
.You'll see that the font-size value applied doesn't match the values defined in
theme.json
.Screenshots, screen recording, code snippet
No response
Environment info
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: