Skip to content

Global Styles: Font Appearance doesn't work well with theme.json default value #70937

@t-hamano

Description

@t-hamano

Description

If the theme.json defines a default fontWeight, there are two problems in the Global Styles UI:

  • Shown as a resettable value even though it is already the default value
  • Keyword values such as bold, regular etc. are not being applied to the dropdown

Perhaps the FontAppearanceControl component is not properly mapping number values and keyword values.

Step-by-step reproduction instructions

After defining the theme.json like the one below, access the Global Styles > Typography panel.

Note

If you are unable to reproduce the problem, reset the global styles.
Image

Number Value (font-weight: 700)

Define the following theme.json:

{
	"version": 3,
	"settings": {
		"appearanceTools": true,
		"layout": {
			"contentSize": "840px"
		}
	},
	"styles": {
		"typography": {
			"fontWeight": "700"
		}
	}
}
  • Expected: The reset button should be disabled when the font-weight value has already been defaulted
  • Actual: The reset button is always enabled
fdc5998218550c73ca703a02c242b64d.mp4

Keyword Value (font-weight: bold)

Define the following theme.json:

{
	"version": 3,
	"settings": {
		"appearanceTools": true,
		"layout": {
			"contentSize": "840px"
		}
	},
	"styles": {
		"typography": {
			"fontWeight": "bold"
		}
	}
}
  • Expected: "Bold" is selected
  • Actual: "Thin" is selected
Image

Screenshots, screen recording, code snippet

No response

Environment info

No response

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

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure

Metadata

Metadata

Assignees

Labels

Global StylesAnything related to the broader Global Styles efforts, including Styles Engine and theme.json[Feature] TypographyFont and typography-related issues and PRs[Status] In ProgressTracking issues with work in progress[Type] BugAn existing feature does not function as intended

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions