Skip to content

Typography: Font size picker crashes when no font size preset exists #62072

@t-hamano

Description

@t-hamano

Description

If no font size presets exist, including the default preset, changing the font size value causes the block to crash.

react-dom.development.js:22873 Uncaught TypeError: fontSizeValue?.startsWith is not a function
    at styleToAttributes (typography.js:56:38)
    at onChange (typography.js:127:18)
    at setFontSize (typography-panel.js:209:3)
    at onChange (index.tsx:216:19)
    at Object.handleOnQuantityChange [as onChange] (index.tsx:145:15)
    at Object.onChange [as onChangeHandler] (utils.ts:101:9)
    at reducer.ts:212:21
    at commitHookEffectListMount (react-dom.development.js:23184:26)
    at commitLayoutEffectOnFiber (react-dom.development.js:23302:17)
    at commitLayoutMountEffects_complete (react-dom.development.js:24722:9)

Step-by-step reproduction instructions

  • Enable Emptytheme.

  • Update theme.json with the code below.

    {
    	"$schema": "../../schemas/json/theme.json",
    	"version": 3,
    	"settings": {
    		"layout": {
    			"contentSize": "840px",
    			"wideSize": "1100px"
    		},
    		"color": {
    			"defaultPalette": false
    		},
    		"typography": {
    			"defaultFontSizes": false
    		}
    	}
    }
  • Open the typography panel for the paragraph block.

  • ❌ Problem 1: The font size picker renders an empty dropdown. I think the dropdown itself should be disabled.

  • Click the "Set custom size" button.

  • ❌ Problem 2: Changing the value should cause the block to crash.

Screenshots, screen recording, code snippet

1f0fe334704ada408b14f6f1b7d5b9bb.mp4

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Feature] TypographyFont and typography-related issues and PRs[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