Skip to content

Fluid "fontSizes" in theme.json break when "size" attribute for two sizes is identical #52191

@susurruses

Description

@susurruses

Description

When creating custom fluid fontSizes in theme.json, sometimes it's desirable to have the same min size but increase to a larger max size. Currently, if you set the size attribute to be the same across different fontSizes, this causes a bug in the editor where you can't select the size that has a matching size applied.

theme.json Example Code:

"fontSizes": [
	{
		"fluid": {
			"min": "1rem",
			"max": "1.25rem"
		},
		"size": "1rem",
		"slug": "small"
	},
	{
		"fluid": {
			"min": "1rem",
			"max": "1.5rem"
		},
		"size": "1rem",
		"slug": "medium"
	}
]

Editor error:
fontSizes-bug

This issue can be fixed by setting different size attributes, but for code readability and consistency sometimes it's desirable to assign this number based on the min or max size, and there are niche instances where a developer might be forced to set this to an arbitrary number to avoid the editor bug.

Step-by-step reproduction instructions

  1. Create a clean install of WordPress, with the twentytwentythree theme.
  2. Edit theme.json, setting multiple fontSizes to the same number (e.g., set line 255 to 1rem and line 263 to 1rem)
  3. Try to assign these sizes within the editor, e.g. on a Paragraph block.

Screenshots, screen recording, code snippet

No response

Environment info

  • WordPress 6.2.2
  • twentytwentythree, version 1.1

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

Metadata

Metadata

Assignees

Labels

[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
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions