Skip to content

Commit

Permalink
Insert default block if no blocks are present
Browse files Browse the repository at this point in the history
  • Loading branch information
stokesman committed Sep 3, 2024
1 parent 036988a commit 8839ca6
Showing 1 changed file with 1 addition and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,13 @@ export function usePaddingAppender() {
.getBlockOrder( '' );
const lastBlockClientId = blockOrder[ blockOrder.length - 1 ];

// Do nothing when only default block appender is present.
if ( ! lastBlockClientId ) {
return;
}

const lastBlock = registry
.select( blockEditorStore )
.getBlock( lastBlockClientId );
const { selectBlock, insertDefaultBlock } =
registry.dispatch( blockEditorStore );

if ( isUnmodifiedDefaultBlock( lastBlock ) ) {
if ( lastBlock && isUnmodifiedDefaultBlock( lastBlock ) ) {
selectBlock( lastBlockClientId );
} else {
insertDefaultBlock();
Expand Down

0 comments on commit 8839ca6

Please sign in to comment.