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 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 );