From b43fbc071274037b82d173c81c332aba09adefa9 Mon Sep 17 00:00:00 2001 From: Kevin Zoschke Date: Wed, 27 Sep 2023 12:28:02 -0400 Subject: [PATCH 1/2] Fix block exception in site editor --- projects/plugins/jetpack/extensions/editor.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/projects/plugins/jetpack/extensions/editor.js b/projects/plugins/jetpack/extensions/editor.js index 6a3e467ab4027..c69851a13b86a 100644 --- a/projects/plugins/jetpack/extensions/editor.js +++ b/projects/plugins/jetpack/extensions/editor.js @@ -86,14 +86,21 @@ function setBetaBlockTitle( settings, name ) { const { title, keywords } = settings; const titleSuffix = '(beta)'; const betaKeyword = 'beta'; - - return { + const result = { ...settings, - title: title.toLowerCase().endsWith( titleSuffix ) - ? title - : `${ settings.title } ${ titleSuffix }`, - kewords: keywords.includes( betaKeyword ) ? keywords : [ ...keywords, betaKeyword ], }; + + if ( title ) { + result.title = title.toLowerCase().endsWith( titleSuffix ) + ? title + : `${ settings.title } ${ titleSuffix }`; + } + + if ( Array.isArray( keywords ) ) { + result.keywords = keywords.includes( betaKeyword ) ? keywords : [ ...keywords, betaKeyword ]; + } + + return result; } addFilter( 'blocks.registerBlockType', 'jetpack/label-beta-blocks-title', setBetaBlockTitle ); From 576527c295bfcd72b118e63064666a59aae4f061 Mon Sep 17 00:00:00 2001 From: Kevin Zoschke Date: Wed, 27 Sep 2023 12:28:53 -0400 Subject: [PATCH 2/2] changelog --- .../jetpack/changelog/fix-blocks-site-editor-exception | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 projects/plugins/jetpack/changelog/fix-blocks-site-editor-exception diff --git a/projects/plugins/jetpack/changelog/fix-blocks-site-editor-exception b/projects/plugins/jetpack/changelog/fix-blocks-site-editor-exception new file mode 100644 index 0000000000000..dfcd6f8a45ae4 --- /dev/null +++ b/projects/plugins/jetpack/changelog/fix-blocks-site-editor-exception @@ -0,0 +1,4 @@ +Significance: patch +Type: bugfix + +Fix block exception throw in Site Editor