@@ -5,7 +5,7 @@ import { GlobalTypographyStyles } from './editor-loader'
55import TypographyPicker from './typography-picker'
66import { getThemeStyles } from './get-theme-styles'
77import FREE_FONT_PAIRS from './font-pairs.json'
8- import { getAppliedTypeScale } from './utils'
8+ import { getAppliedTypeScale , cleanTypographyStyle } from './utils'
99
1010/**
1111 * External dependencies
@@ -313,13 +313,9 @@ addFilter( 'stackable.global-settings.inspector', 'stackable/global-typography',
313313 * Otherwise, the API will throw an error code 400
314314 * because of incompatible schema type.
315315 */
316- Object . keys ( styles ) . forEach ( key => {
317- if ( styles [ key ] === '' ) {
318- delete styles [ key ]
319- }
320- } )
316+ const cleanStyles = cleanTypographyStyle ( styles ) || { }
321317
322- newSettings [ selector ] = styles
318+ newSettings [ selector ] = cleanStyles
323319 } )
324320
325321 // Update the global styles immediately when reset font size is triggered.
@@ -353,9 +349,10 @@ addFilter( 'stackable.global-settings.inspector', 'stackable/global-typography',
353349
354350 const getIsAllowReset = selector => {
355351 const currentFontPair = getCurrentFontPair ( )
356- const typographyStyle = typographySettings [ selector ]
352+ const typographyStyle = typographySettings [ selector ] || { }
357353 if ( ! isEditingFontPair && currentFontPair ) {
358- const fontPairStyle = currentFontPair . typography [ selector ]
354+ // Clean style object to be consistent with changeStyles operation
355+ const fontPairStyle = cleanTypographyStyle ( currentFontPair . typography ?. [ selector ] ) || { }
359356 if ( ! isEqual ( fontPairStyle , typographyStyle ) && ! Array . isArray ( typographyStyle ) ) {
360357 return true
361358 }
@@ -385,8 +382,9 @@ addFilter( 'stackable.global-settings.inspector', 'stackable/global-typography',
385382 if ( isEditingFontPair || ! currentFontPair ) {
386383 return false
387384 }
388- const fontPairStyle = currentFontPair . typography [ selector ]
389- const typographyStyle = typographySettings [ selector ]
385+ // Clean style object to be consistent with changeStyles operation
386+ const fontPairStyle = cleanTypographyStyle ( currentFontPair . typography ?. [ selector ] ) || { }
387+ const typographyStyle = typographySettings [ selector ] || { }
390388
391389 if ( ! Array . isArray ( typographyStyle ) &&
392390 fontPairStyle . fontFamily &&
0 commit comments