Skip to content

Commit c68c82c

Browse files
authored
Fix block exception throw in Site Editor (#33350)
* Fix block exception in site editor * changelog
1 parent c6a2f4b commit c68c82c

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: patch
2+
Type: bugfix
3+
4+
Fix block exception throw in Site Editor

projects/plugins/jetpack/extensions/editor.js

+13-6
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,21 @@ function setBetaBlockTitle( settings, name ) {
8686
const { title, keywords } = settings;
8787
const titleSuffix = '(beta)';
8888
const betaKeyword = 'beta';
89-
90-
return {
89+
const result = {
9190
...settings,
92-
title: title.toLowerCase().endsWith( titleSuffix )
93-
? title
94-
: `${ settings.title } ${ titleSuffix }`,
95-
kewords: keywords.includes( betaKeyword ) ? keywords : [ ...keywords, betaKeyword ],
9691
};
92+
93+
if ( title ) {
94+
result.title = title.toLowerCase().endsWith( titleSuffix )
95+
? title
96+
: `${ settings.title } ${ titleSuffix }`;
97+
}
98+
99+
if ( Array.isArray( keywords ) ) {
100+
result.keywords = keywords.includes( betaKeyword ) ? keywords : [ ...keywords, betaKeyword ];
101+
}
102+
103+
return result;
97104
}
98105

99106
addFilter( 'blocks.registerBlockType', 'jetpack/label-beta-blocks-title', setBetaBlockTitle );

0 commit comments

Comments
 (0)