From c16ef91e042b127b3700201588cba87f3b3caf57 Mon Sep 17 00:00:00 2001 From: Allen Benny Date: Fri, 1 Mar 2024 12:47:40 +0530 Subject: [PATCH 1/2] Add fail safe checks --- src/OnboardingSPA/steps/SiteGen/Preview/index.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/OnboardingSPA/steps/SiteGen/Preview/index.js b/src/OnboardingSPA/steps/SiteGen/Preview/index.js index 0b058df29..176bf90a9 100644 --- a/src/OnboardingSPA/steps/SiteGen/Preview/index.js +++ b/src/OnboardingSPA/steps/SiteGen/Preview/index.js @@ -245,10 +245,11 @@ const SiteGenPreview = () => { const newPreviewSettings = cloneDeep( globalStyles[ 0 ] ); newPreviewSettings.settings.color.palette = data.color.palette; const body = - data.styles?.blocks[ 0 ]?.[ 'core/body' ].typography.fontFamily; + data.styles?.blocks[ 0 ]?.[ 'core/body' ]?.typography + ?.fontFamily; const headings = - data.styles?.blocks[ 0 ]?.[ 'core/heading' ].typography - .fontFamily; + data.styles?.blocks[ 0 ]?.[ 'core/heading' ]?.typography + ?.fontFamily; if ( newPreviewSettings.styles.typography ) { newPreviewSettings.styles.typography.fontFamily = body; } From 1683701eb9d20585d7ca699e07720562f7ccc536 Mon Sep 17 00:00:00 2001 From: Allen Benny Date: Fri, 1 Mar 2024 13:34:13 +0530 Subject: [PATCH 2/2] More Checks :eyes: --- src/OnboardingSPA/steps/SiteGen/Preview/index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/OnboardingSPA/steps/SiteGen/Preview/index.js b/src/OnboardingSPA/steps/SiteGen/Preview/index.js index 176bf90a9..41353b534 100644 --- a/src/OnboardingSPA/steps/SiteGen/Preview/index.js +++ b/src/OnboardingSPA/steps/SiteGen/Preview/index.js @@ -250,11 +250,12 @@ const SiteGenPreview = () => { const headings = data.styles?.blocks[ 0 ]?.[ 'core/heading' ]?.typography ?.fontFamily; - if ( newPreviewSettings.styles.typography ) { + if ( newPreviewSettings.styles.typography && body ) { newPreviewSettings.styles.typography.fontFamily = body; } if ( - newPreviewSettings.styles.blocks[ 'core/heading' ].typography + newPreviewSettings.styles.blocks[ 'core/heading' ].typography && + headings ) { newPreviewSettings.styles.blocks[ 'core/heading'