From 1c3e7bedddb02d64d40186e60f67f94e34175b35 Mon Sep 17 00:00:00 2001 From: Sarah Norris <1645628+mikachan@users.noreply.github.com> Date: Thu, 1 Aug 2024 09:40:01 +0100 Subject: [PATCH] TypesetButton: Check if variations exist before running logic (#64139) * Check if variations exists before running find * Add allFontFamilies to deps array Co-authored-by: mikachan Co-authored-by: scruffian --- .../edit-site/src/components/global-styles/typeset-button.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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..81955627526595 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' ) @@ -60,7 +60,7 @@ function TypesetButton() { return activeVariation.title; } return allFontFamilies.map( ( font ) => font?.name ).join( ', ' ); - }, [ userTypographyConfig, variations ] ); + }, [ allFontFamilies, userTypographyConfig, variations ] ); return ( hasFonts && (