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

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

Open
t-hamano opened this issue May 28, 2024 · 0 comments
Open

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

t-hamano opened this issue May 28, 2024 · 0 comments
Labels
[Feature] Typography Font and typography-related issues and PRs [Type] Bug An existing feature does not function as intended

Comments

@t-hamano
Copy link
Contributor

t-hamano commented May 28, 2024

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

@t-hamano t-hamano added [Type] Bug An existing feature does not function as intended [Feature] Typography Font and typography-related issues and PRs labels May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Typography Font and typography-related issues and PRs [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

1 participant