Skip to content

Commit

Permalink
Fix block exception in site editor
Browse files Browse the repository at this point in the history
  • Loading branch information
monsieur-z committed Sep 28, 2023
1 parent 295c743 commit b43fbc0
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions projects/plugins/jetpack/extensions/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down

0 comments on commit b43fbc0

Please sign in to comment.