Skip to content

Commit

Permalink
Add default block after pressing enter at the end of Site Title (#30996)
Browse files Browse the repository at this point in the history
  • Loading branch information
ntsekouras authored Apr 20, 2021
1 parent b3fe0be commit 326554b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/block-library/src/site-title/edit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }`;
Expand Down Expand Up @@ -56,6 +61,11 @@ export default function SiteTitleEdit( { attributes, setAttributes } ) {
onChange={ setTitle }
allowedFormats={ [] }
disableLineBreaks
__unstableOnSplitAtEnd={ () =>
insertBlocksAfter(
createBlock( getDefaultBlockName() )
)
}
/>
</TagName>
</>
Expand Down

0 comments on commit 326554b

Please sign in to comment.