Skip to content

Commit

Permalink
fix: Added typeof check in fontSizeValue
Browse files Browse the repository at this point in the history
  • Loading branch information
im3dabasia committed Jan 17, 2025
1 parent 041ca27 commit e5dfb84
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
8 changes: 5 additions & 3 deletions packages/block-editor/src/hooks/typography.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ function styleToAttributes( style ) {
const updatedStyle = { ...omit( style, [ 'fontFamily' ] ) };
const fontSizeValue = style?.typography?.fontSize;
const fontFamilyValue = style?.typography?.fontFamily;
const fontSizeSlug = fontSizeValue?.startsWith( 'var:preset|font-size|' )
? fontSizeValue.substring( 'var:preset|font-size|'.length )
: undefined;
const fontSizeSlug =
typeof fontSizeValue === 'string' &&
fontSizeValue?.startsWith( 'var:preset|font-size|' )
? fontSizeValue.substring( 'var:preset|font-size|'.length )
: undefined;
const fontFamilySlug = fontFamilyValue?.startsWith(
'var:preset|font-family|'
)
Expand Down
17 changes: 7 additions & 10 deletions test/emptytheme/theme.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,15 @@
"$schema": "../../schemas/json/theme.json",
"version": 3,
"settings": {
"appearanceTools": true,
"layout": {
"contentSize": "840px",
"wideSize": "1100px"
},
"color": {
"defaultPalette": false
},
"typography": {
"defaultFontSizes": false
}
},
"customTemplates": [
{
"name": "custom-template",
"title": "Custom",
"postTypes": [ "post" ]
}
],
"patterns": [ "short-text-surrounded-by-round-images", "partner-logos" ]
}
}

0 comments on commit e5dfb84

Please sign in to comment.