From 326554bc26baddbb680bf2d95ec8df001ed0539c Mon Sep 17 00:00:00 2001 From: Nik Tsekouras Date: Tue, 20 Apr 2021 16:27:20 +0300 Subject: [PATCH] Add default block after pressing enter at the end of Site Title (#30996) --- packages/block-library/src/site-title/edit/index.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/block-library/src/site-title/edit/index.js b/packages/block-library/src/site-title/edit/index.js index 0805d4ed72db3d..b1f9331520294b 100644 --- a/packages/block-library/src/site-title/edit/index.js +++ b/packages/block-library/src/site-title/edit/index.js @@ -14,13 +14,18 @@ import { BlockControls, useBlockProps, } from '@wordpress/block-editor'; +import { createBlock, getDefaultBlockName } from '@wordpress/blocks'; /** * Internal dependencies */ import LevelToolbar from './level-toolbar'; -export default function SiteTitleEdit( { attributes, setAttributes } ) { +export default function SiteTitleEdit( { + attributes, + setAttributes, + insertBlocksAfter, +} ) { const { level, textAlign } = attributes; const [ title, setTitle ] = useEntityProp( 'root', 'site', 'title' ); const TagName = level === 0 ? 'p' : `h${ level }`; @@ -56,6 +61,11 @@ export default function SiteTitleEdit( { attributes, setAttributes } ) { onChange={ setTitle } allowedFormats={ [] } disableLineBreaks + __unstableOnSplitAtEnd={ () => + insertBlocksAfter( + createBlock( getDefaultBlockName() ) + ) + } />