Skip to content

Commit eb77f8d

Browse files
committed
fix: error when no previously selected font pair
1 parent 44acb2c commit eb77f8d

File tree

1 file changed

+4
-4
lines changed
  • src/plugins/global-settings/typography

1 file changed

+4
-4
lines changed

src/plugins/global-settings/typography/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ addFilter( 'stackable.global-settings.inspector', 'stackable/global-typography',
8080
const [ typographySettings, setTypographySettings ] = useState( [] )
8181
const [ applySettingsTo, setApplySettingsTo ] = useState( '' )
8282
const [ customFontPairs, setCustomFontPairs ] = useState( [] )
83-
const [ selectedFontPairName, setSelectedFontPairName ] = useState( 'theme-heading-default/theme-body-default' )
83+
const [ selectedFontPairName, setSelectedFontPairName ] = useState( '' )
8484
const [ editingFontPairName, setEditingFontPairName ] = useState( '' )
8585

8686
const fontPairContainerRef = useRef( null )
@@ -187,7 +187,7 @@ addFilter( 'stackable.global-settings.inspector', 'stackable/global-typography',
187187
const resetStyles = selector => {
188188
let newSettings
189189
const currentFontPair = [ ...FONT_PAIRS, ...customFontPairs ].find( fontPair => fontPair.name === selectedFontPairName )
190-
if ( ! editingFontPairName ) {
190+
if ( ! editingFontPairName && currentFontPair ) {
191191
newSettings = { ...typographySettings, [ selector ]: currentFontPair.typography[ selector ] }
192192
} else {
193193
newSettings = omit( typographySettings, [ selector ] )
@@ -211,9 +211,9 @@ addFilter( 'stackable.global-settings.inspector', 'stackable/global-typography',
211211

212212
const getIsAllowReset = selector => {
213213
const currentFontPair = [ ...FONT_PAIRS, ...customFontPairs ].find( fontPair => fontPair.name === selectedFontPairName )
214-
const fontPairStyle = currentFontPair.typography[ selector ]
215214
const typographyStyle = typographySettings[ selector ]
216-
if ( ! editingFontPairName ) {
215+
if ( ! editingFontPairName && currentFontPair ) {
216+
const fontPairStyle = currentFontPair.typography[ selector ]
217217
if ( ! isEqual( fontPairStyle, typographyStyle ) ) {
218218
return true
219219
}

0 commit comments

Comments
 (0)