From 143fe4cd94ed19384d3bae68aa751c2ed641e45a Mon Sep 17 00:00:00 2001 From: Adam Boro Date: Thu, 12 Nov 2020 10:03:46 +0100 Subject: [PATCH] fix: editor crash when in code mode (#370) --- src/newsletter-editor/styling/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/newsletter-editor/styling/index.js b/src/newsletter-editor/styling/index.js index d42c819a3..8f8ed6922 100644 --- a/src/newsletter-editor/styling/index.js +++ b/src/newsletter-editor/styling/index.js @@ -80,7 +80,10 @@ export const ApplyStyling = withSelect( customStylesSelector )( document.documentElement.style.setProperty( '--header-font', fontHeader ); }, [ fontHeader ]); useEffect(() => { - document.querySelector( '.edit-post-visual-editor' ).style.backgroundColor = backgroundColor; + const editorElement = document.querySelector( '.edit-post-visual-editor' ); + if ( editorElement ) { + editorElement.style.backgroundColor = backgroundColor; + } }, [ backgroundColor ]); return null;