Skip to content

Commit

Permalink
Fix list outdents on Enter in quote block (#44809)
Browse files Browse the repository at this point in the history
  • Loading branch information
benridane authored and michalczaplinski committed Oct 18, 2022
1 parent 6ef0ed8 commit a5efd9d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,16 @@ export default function useOutdentListItem( clientId ) {
const registry = useRegistry();
const { canOutdent } = useSelect(
( innerSelect ) => {
const { getBlockRootClientId } = innerSelect( blockEditorStore );
const { getBlockRootClientId, getBlockName } =
innerSelect( blockEditorStore );
const grandParentId = getBlockRootClientId(
getBlockRootClientId( clientId )
);
const grandParentName = getBlockName( grandParentId );
const isListItem = grandParentName === listItemName;

return {
canOutdent: !! grandParentId,
canOutdent: isListItem,
};
},
[ clientId ]
Expand Down
26 changes: 26 additions & 0 deletions test/e2e/specs/editor/blocks/list.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,32 @@ test.describe( 'List', () => {
);
} );

test( 'should create paragraph on Enter in quote block', async ( {
editor,
page,
} ) => {
await editor.insertBlock( { name: 'core/quote' } );
await page.keyboard.type( '/list' );
await page.keyboard.press( 'Enter' );
await page.keyboard.type( 'aaa' );
await page.keyboard.press( 'Enter' );
await page.keyboard.press( 'Enter' );

await expect.poll( editor.getEditedPostContent ).toBe(
`<!-- wp:quote -->
<blockquote class="wp-block-quote"><!-- wp:list -->
<ul><!-- wp:list-item -->
<li>aaa</li>
<!-- /wp:list-item --></ul>
<!-- /wp:list -->
<!-- wp:paragraph -->
<p></p>
<!-- /wp:paragraph --></blockquote>
<!-- /wp:quote -->`
);
} );

test( 'should indent and outdent level 1', async ( { editor, page } ) => {
await editor.insertBlock( { name: 'core/list' } );
await page.keyboard.type( 'a' );
Expand Down

0 comments on commit a5efd9d

Please sign in to comment.