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

Fluid typography in theme.json loads just the default size in the site editor #42680

Closed
matiasbenedetto opened this issue Jul 25, 2022 · 4 comments · Fixed by #42688
Closed
Assignees
Labels
[Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") [Feature] Typography Font and typography-related issues and PRs Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Type] Bug An existing feature does not function as intended

Comments

@matiasbenedetto
Copy link
Contributor

matiasbenedetto commented Jul 25, 2022

Description

When you use the fluid typography API recently introduced in Gutenberg, the min and max settings are ignored in the editor and it just loads the default value.

Step-by-step reproduction instructions

  1. Add a new fluid font size in your fontSizes array (settings.typography.fontSizes) in theme.json and save.
  {
      "size": "1.3rem",
      "fluid": {
          "min": "1.3rem",
          "max": "2.5rem"
      },
      "slug": "default-title",
      "name": "Default Title"
  }
  1. Set the fonstSize for a block in your theme.json (styles.blocks).
"core/post-navigation-link": {
      "typography": {
          "fontSize": "var(--wp--preset--font-size--default-title)"
      }
  }
  1. Open the editor and add a block to a template and save.
  2. Save and navigate the frontend. The block should have a fluid font size.
  3. Reload the editor and verify that the font size of the block is NOT fluid.

Screenshots, screen recording, code snippet

Frontend:
image

Editor:
image

Environment info

  • Wordpress 6
  • 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

@matiasbenedetto matiasbenedetto added [Package] Editor /packages/editor [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. labels Jul 25, 2022
@pagelab
Copy link
Contributor

pagelab commented Jul 25, 2022

Did you add "fluid": true, to settings.typography? I can reproduce this issue only if it is removed.

@matiasbenedetto
Copy link
Contributor Author

Did you add "fluid": true, to settings.typography? I can reproduce this issue only if it is removed.

Hi @pagelab, thanks for testing. Please try using the template editor as suggested in the step-by-step reproduction instructions.

This seems to be working fine on the post editor but failing on the template editor (Appearance -> Editor from the WP sidebar menu).

@pagelab
Copy link
Contributor

pagelab commented Jul 25, 2022

I see. I confirm, it's not working in the template editor, just in the regular post editor.

@ramonjd
Copy link
Member

ramonjd commented Jul 26, 2022

Thanks for registering this bug.

It appears to be an existing bug, unrelated to the fluid typography changes, whereby the font size presets are printed twice to the page:

  1. In a style tag in the document's head (global-styles-css-custom-properties-inline-css). The presets are printed before any processing takes place.
  2. And again, at the bottom of the page, in wp.editSite.initializeEditor, where the processing has taken place and the clamp values are visible.

The former, at least in the template/site editor, are taking precedence over the latter.

It looks like it's a bug with any preset that defines its value via a value_func. So duotone is exhibiting the same behaviour.

The fluid typography changes do highlight the need for this to be addressed. I'll take a look and see if I can hunt down the cause.

Edit: Oh, it looks like we also need a JS version of the fluid font size algorithm for the site editor only (because it's in an iframe)

@ramonjd ramonjd added [Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json and removed [Package] Editor /packages/editor labels Jul 26, 2022
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Jul 26, 2022
@ramonjd ramonjd added [Feature] Typography Font and typography-related issues and PRs [Type] Bug An existing feature does not function as intended and removed [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. labels Jul 26, 2022
@ramonjd ramonjd changed the title Fluid typography in theme.json loads just the default size in the editor Fluid typography in theme.json loads just the default size in the site editor Jul 27, 2022
@priethor priethor removed the [Status] In Progress Tracking issues with work in progress label May 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") [Feature] Typography Font and typography-related issues and PRs Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants