gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

Setting styles.typography.fontWeight in theme.json crashes editor

Open mkaz opened this issue 5 years ago • 3 comments

Description

If I set the following in my theme.json file using a block theme, it causes an editor crash that it can not recover from.

{
    "version": 1,
    "styles": {
		"typography": {
			"fontFamily": "'IBM Plex Serif', 'Droid Serif', Georgia, serif",
			"fontSize": "var(--wp--preset--font-size--normal)",
			"fontWeight": "300"
		}
	}	
}

If I remove the fontWeight line (correcting commas as needed) then the editor loads properly, adding it back in it breaks.

Step-by-step reproduction instructions

  • Use a block theme
  • Edit theme.json and add styles.typography.fontWeight
  • Load editor

Screenshots, screen recording, code snippet

No response

Environment info

  • WP 5.8
  • Latest Gutenberg plugin from trunk

Pre-checks

  • [X] I have searched the existing issues.
  • [X] I have tested with all plugins deactivated except Gutenberg.

mkaz avatar Sep 02 '21 03:09 mkaz

I am also able to reproduce this issue.

I noticed also that if the Global Styles sidebar is initially closed, the Site Editor loads OK. Opening the sidebar or if was previously opened state, the Site Editor crashes.

Interestingly if I also include "fontStyle" e.g. "fontStyle": "normal" the Site Editor does not crash, and functions as it should.

For example this works OK:

{
    "version": 1,
    "styles": {
		"typography": {
			"fontFamily": "'IBM Plex Serif', 'Droid Serif', Georgia, serif",
			"fontSize": "var(--wp--preset--font-size--normal)",
			"fontWeight": "300",
			"fontStyle": "normal"
		}
	}	
}

Sandstromer avatar Sep 02 '21 10:09 Sandstromer

I can't replicate this anymore using version 2 of theme.json with 5.9. Is this still an issue for you @mkaz?

annezazu avatar Feb 09 '22 07:02 annezazu

This works as expected in v2 of theme.json so closing for now. Feel free to reopen @mkaz if it is still an issue for you in v2 theme.json.

glendaviesnz avatar Apr 12 '23 22:04 glendaviesnz