Skip to content
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

Typography: Theme defined font sizes are no longer working #57889

Closed
iamtakashi opened this issue Jan 16, 2024 · 21 comments · Fixed by #58456
Closed

Typography: Theme defined font sizes are no longer working #57889

iamtakashi opened this issue Jan 16, 2024 · 21 comments · Fixed by #58456
Assignees
Labels
[Feature] Typography Font and typography-related issues and PRs [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@iamtakashi
Copy link

iamtakashi commented Jan 16, 2024

Description

It looks like the font sizes a theme defines in its theme.json are no longer working.

without plugin with plugin
localhost local_ (12) localhost local_ (13)

For example, in the theme, --wp--preset--font-size--medium should be 1.05rem but with Gutenberg plugin, the size is clamp(14px, 0.875rem + ((1vw - 3.2px) * 0.625), 20px)

I can see this issue with other themes too.

Step-by-step reproduction instructions

  1. Open a homepage in the browser.
  2. Deactivate Gutenberg trunk
  3. Open the homepage in a new tab
  4. Notice the difeerence

Screenshots, screen recording, code snippet

No response

Environment info

  • WP 6.4.2
  • Gutenberg Trunk

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

@iamtakashi iamtakashi added the [Type] Bug An existing feature does not function as intended label Jan 16, 2024
@jordesign jordesign added the [Feature] Typography Font and typography-related issues and PRs label Jan 16, 2024
@bgardner
Copy link

Can also confirm this is happening.

@bgardner
Copy link

bgardner commented Jan 19, 2024

Pinging @richtabor and @annezazu b/c IMO this is a pretty big deal (and breaking situation).

@bgardner
Copy link

bgardner commented Jan 22, 2024

To further illustrate what is happening, see below. Gutenberg trunk seems to exacerbate the problem with even more unexpected results and—in this case—breaking changes on the front end.

What font sizes should be in my Powder theme:

image

What is output with Gutenberg 17.5 active:

image

@bgardner
Copy link

Perhaps this is related (or has similar behavior) to #52200.

Also pinging @carolinan as she was involved in the issue I mentioned.

@colorful-tones
Copy link
Member

@ajlende, could this be a side-effect or regression from work introduced in #56661 ? Can you take a peek, please?

@iamtakashi
Copy link
Author

@bgardner @colorful-tones, thanks for adding more context.

It'd be great if this issue gets fixed quickly. It blocks theme creations if you use the trunk :/

@annezazu
Copy link
Contributor

I'll escalate where I can too. Thank you for the ping and raising the alarm.

@annezazu annezazu moved this to 📥 Todo in WordPress 6.5 Editor Tasks Jan 23, 2024
@annezazu annezazu changed the title theme defined font sizes are no longer working. Typography: Theme defined font sizes are no longer working Jan 23, 2024
@ajlende ajlende self-assigned this Jan 24, 2024
@bgardner
Copy link

Can’t wait to see what you come up with @ajlende, as Gutenberg 17.6 RC1 now has breaking changes on the front end with font sizes.

@iamtakashi
Copy link
Author

iamtakashi commented Jan 29, 2024

Any progress on this? The first comparison images with TT4 might not have illustrated the issue very much because the difference was subtle 🔍

The extent of the disturbance depends on the design of the theme, and this example might illustrate the issue better. The left is how it should be and the right is the current.

Screenshot 2024-01-29 at 13 47 04

@SantosGuillamot
Copy link
Contributor

SantosGuillamot commented Jan 29, 2024

I am far from an expert in how those properties are handled in Gutenberg, but maybe changing the prevent_override to false solves the problem: link.

prevent_override => false

I've tested that and, making that change, it seems to work for my case:

  • If I have a theme.json with sizes with the same slug as the default ones ("small", "medium", "large"...) the value from the theme takes precedence over the default value in Gutenberg.
  • If I remove the fontSizes from the theme, they still appear now with the values provided by Gutenberg.

Is that what we want? If that should be the solution I can work on a pull request.

EDIT: I ended up creating the pull request in case I'm not around and we need to merge this. Feel free to suggest/modify anything.

@ajlende
Copy link
Contributor

ajlende commented Jan 29, 2024

@SantosGuillamot Thanks for taking a look! I've also been working on this and commented in the PR that caused the issue (#56661). It'll be helpful if you can review when I get it working.

This PR changed the default value for prevent_override to be the value of defaultFontSizes which is true by default. Previously prevent_override was false, so now any theme defined font sizes that use the same slugs as the default font sizes (small, medium, large, etc.) are no longer overridden by their theme counterparts. I didn't think this was an issue because of the bug described in #56661 (comment). However, apparently in some cases the ordering was correct, so this change broke those sites.

The value for defaultFontSizes can't be set to false because it is also in control of the UI, and themes that don't define custom font sizes would no longer show the defaults. So I'm planning on adding a third value "legacy" or something that global styles can interpret as prevent_override being false, but the UI can interpret as defaultFontSizes being true so that they are all shown.

So both the ordering bug and the legacy behavior both need to be added to fix this issue which is why there are delays.

@SantosGuillamot
Copy link
Contributor

Great to hear you are working on that 🙂

The value for defaultFontSizes can't be set to false because it is also in control of the UI, and themes that don't define custom font sizes would no longer show the defaults.

Oh, that's a pity. I can test whatever the solution is, although I'm not gonna be available until tomorrow.

@bgardner
Copy link

bgardner commented Jan 30, 2024

Noting that while the front end is better/fixed, the font sizes in the editor (Typography > Size) are still being hijacked by core sizes. In other words, the screenshots from my comment above are still an issue.

cc: @annezazu for visibility and @iamtakashi to confirm if seeing the same thing.

@bgardner
Copy link

To re-iterate, these were just taken with/without Gutenberg 17.6.0-rc.3 active.

Gutenberg not active:

image

Gutenberg active:

image

@justintadlock justintadlock reopened this Jan 30, 2024
@justintadlock
Copy link
Contributor

Just reopening if this is still an ongoing issue and not fully corrected with the latest change.

@justintadlock
Copy link
Contributor

@bgardner - Just to help me understand the current issue:

From what I'm seeing in your latest screenshots is that the core sizes are listed above yours. If that is the only problem, there's a separate issue for that: #52200

Or is it that your custom sizes are not working still?

@bgardner
Copy link

@justintadlock I see that this exists: #52200

The problem is that in the editor, where there are font sizes names common with core/default themes and my Frost/Powder themes (Small, Medium, Large, and Extra Large in this case) the drop down menu shows the core values and not my theme values. With the revert in #58456, the issue is no longer on the front end out of the box—just when text is given any of those sizes listed above (in which case it becomes a front end problem.)

In English: if a theme declares font sizes that are identical to the ones in core, core should defer altogether (front end, back end, site editor) to the theme.

@ktmn
Copy link

ktmn commented Jan 31, 2024

Theme defined font sizes are no longer working

For me I have turned off every style, but with Gutenberg 6.4.3 (since 6.4.0 iirc) font size is back

theme.json:

{
	"$schema": "https://schemas.wp.org/trunk/theme.json",
	"version": 2,
	"settings": {
		"appearanceTools": false,
		"typography": {
			"defaultFontSizes": false,
			"customFontSize": false,
			"lineHeight": false,
			"dropCap": false,
			"fluid": false,
			"fontStyle": false,
			"fontWeight": false,
			"letterSpacing": false,
			"textDecoration": false,
			"textTransform": false,
			"fontFamilies": [],
			"fontSizes": []
		}
	},

The font size control is back, making the whole "Styles" tab appear:

image

Which also brings back this broken-looking thing, under Advanced:

image


Edit: Gutenberg 17.6.0 - it's still there. defaultFontSizes false/[]/null doesn't turn off the font size control (but it used to).


Edit: Adding:

"blocks": {
	"core/paragraph": {
		"typography": {
			"fontSizes": []
		}
	}
},

Produces empty styles tab with "Typography" label:

image

@t-hamano
Copy link
Contributor

t-hamano commented Feb 1, 2024

Since this issue has been reopened, I will also change the project board status from "Done" to "ToDo".

@t-hamano t-hamano moved this from ✅ Done to 📥 Todo in WordPress 6.5 Editor Tasks Feb 1, 2024
@iamtakashi
Copy link
Author

iamtakashi commented Feb 1, 2024

@bgardner Sorry for the delay in response. I was away.

I can confirm that blocks now appear with the correct font sizes on both the editor and the front of the site, but the sizes with the same slugs as core are labelled incorrectly.

Screenshot 2024-02-01 at 15 00 44

@scruffian
Copy link
Contributor

I think the original issue caused by #56661 which was resolved when we reverted in #58456.

The original issue (#52200) is still open, as is this other one about duplicate font sizes: #57733

I think these two issues cover all the currently known bugs, so I'll close this one in favour of them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Typography Font and typography-related issues and PRs [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
Status: Done