From 777918c593c76bac0632ca389aeca805cb0ba7df Mon Sep 17 00:00:00 2001 From: benridane <15902112+benridane@users.noreply.github.com> Date: Tue, 11 Oct 2022 22:29:50 +0900 Subject: [PATCH] Fix list outdents on Enter in quote block (#44809) --- .../list-item/hooks/use-outdent-list-item.js | 8 ++++-- test/e2e/specs/editor/blocks/list.spec.js | 26 +++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/packages/block-library/src/list-item/hooks/use-outdent-list-item.js b/packages/block-library/src/list-item/hooks/use-outdent-list-item.js index 93472f49dbba8d..d4c034b06e8134 100644 --- a/packages/block-library/src/list-item/hooks/use-outdent-list-item.js +++ b/packages/block-library/src/list-item/hooks/use-outdent-list-item.js @@ -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 ] diff --git a/test/e2e/specs/editor/blocks/list.spec.js b/test/e2e/specs/editor/blocks/list.spec.js index 76c334257387d3..c0133cc73629ac 100644 --- a/test/e2e/specs/editor/blocks/list.spec.js +++ b/test/e2e/specs/editor/blocks/list.spec.js @@ -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( + ` +
+ + + + +

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