Skip to content

Commit

Permalink
TypesetButton: Check if variations exist before running logic (#64139)
Browse files Browse the repository at this point in the history
* Check if variations exists before running find

* Add allFontFamilies to deps array

Co-authored-by: mikachan <mikachan@git.wordpress.org>
Co-authored-by: scruffian <scruffian@git.wordpress.org>
  • Loading branch information
3 people authored Aug 1, 2024
1 parent c04a6f4 commit 1c3e7be
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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' )
Expand All @@ -60,7 +60,7 @@ function TypesetButton() {
return activeVariation.title;
}
return allFontFamilies.map( ( font ) => font?.name ).join( ', ' );
}, [ userTypographyConfig, variations ] );
}, [ allFontFamilies, userTypographyConfig, variations ] );

return (
hasFonts && (
Expand Down

0 comments on commit 1c3e7be

Please sign in to comment.