Skip to content

Commit

Permalink
Address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Jul 22, 2022
1 parent 253707f commit b6a2fa2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 22 deletions.
30 changes: 15 additions & 15 deletions packages/block-editor/src/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1159,28 +1159,28 @@ export const removeBlocks =
return;
}

if ( selectPrevious ) {
dispatch.selectPreviousBlock( clientIds[ 0 ] );
}

dispatch( { type: 'REMOVE_BLOCKS', clientIds } );

const blockOrder = select.getBlockOrder( rootClientId );
const { __unstableRemoveEmpty } =
select.getBlockListSettings( rootClientId ) || {};
const removeEmpty =
blockOrder.length === clientIds.length && __unstableRemoveEmpty;

if ( blockOrder.length === 0 && __unstableRemoveEmpty ) {
if ( selectPrevious ) {
dispatch.selectPreviousBlock( rootClientId );
}
if ( selectPrevious ) {
dispatch.selectPreviousBlock(
removeEmpty ? rootClientId : clientIds[ 0 ]
);
}

dispatch( { type: 'REMOVE_BLOCKS', clientIds } );

if ( removeEmpty ) {
dispatch( { type: 'REMOVE_BLOCKS', clientIds: [ rootClientId ] } );
} else {
// To avoid a focus loss when removing the last block, assure there
// is always a default block if the last of the blocks have been
// removed.
dispatch( ensureDefaultBlock() );
}

// To avoid a focus loss when removing the last block, assure there
// is always a default block if the last of the blocks have been
// removed.
dispatch( ensureDefaultBlock() );
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,6 @@ exports[`Quote can be created by using > at the start of a paragraph block 1`] =
<!-- /wp:quote -->"
`;
exports[`Quote can be removed 1`] = `
"<!-- wp:paragraph -->
<p>ab</p>
<!-- /wp:paragraph -->"
`;
exports[`Quote can be split at the end 1`] = `
"<!-- wp:quote -->
<blockquote class=\\"wp-block-quote\\"><!-- wp:paragraph -->
Expand Down
6 changes: 5 additions & 1 deletion packages/e2e-tests/specs/editor/blocks/quote.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ describe( 'Quote', () => {
await page.keyboard.type( 'b' );

// Expect "ab" in the paragraph.
expect( await getEditedPostContent() ).toMatchSnapshot();
expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
"<!-- wp:paragraph -->
<p>ab</p>
<!-- /wp:paragraph -->"
` );
} );
} );

0 comments on commit b6a2fa2

Please sign in to comment.