From 06fb7a40e9d9718bfe236e55b01c28625008aaee Mon Sep 17 00:00:00 2001 From: Sarah Norris Date: Wed, 31 Jul 2024 13:05:48 +0100 Subject: [PATCH 1/2] Check if variations exists before running find --- .../edit-site/src/components/global-styles/typeset-button.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/edit-site/src/components/global-styles/typeset-button.js b/packages/edit-site/src/components/global-styles/typeset-button.js index d66310f2ed8ff5..d7a4f8201716ca 100644 --- a/packages/edit-site/src/components/global-styles/typeset-button.js +++ b/packages/edit-site/src/components/global-styles/typeset-button.js @@ -49,7 +49,7 @@ function TypesetButton() { if ( Object.keys( userTypographyConfig ).length === 0 ) { return __( 'Default' ); } - const activeVariation = variations.find( ( variation ) => { + const activeVariation = variations?.find( ( variation ) => { return ( JSON.stringify( filterObjectByProperties( variation, 'typography' ) From 5bdf4d660937d506d17261302bd8da500db026d4 Mon Sep 17 00:00:00 2001 From: Sarah Norris Date: Wed, 31 Jul 2024 13:07:16 +0100 Subject: [PATCH 2/2] Add allFontFamilies to deps array --- .../edit-site/src/components/global-styles/typeset-button.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/edit-site/src/components/global-styles/typeset-button.js b/packages/edit-site/src/components/global-styles/typeset-button.js index d7a4f8201716ca..81955627526595 100644 --- a/packages/edit-site/src/components/global-styles/typeset-button.js +++ b/packages/edit-site/src/components/global-styles/typeset-button.js @@ -60,7 +60,7 @@ function TypesetButton() { return activeVariation.title; } return allFontFamilies.map( ( font ) => font?.name ).join( ', ' ); - }, [ userTypographyConfig, variations ] ); + }, [ allFontFamilies, userTypographyConfig, variations ] ); return ( hasFonts && (