From 27ae6ba534039c83026ba1f77b35d652e77db986 Mon Sep 17 00:00:00 2001 From: Ella Date: Thu, 14 Dec 2023 20:06:02 +0100 Subject: [PATCH] Combine select --- packages/block-library/src/list-item/edit.js | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/packages/block-library/src/list-item/edit.js b/packages/block-library/src/list-item/edit.js index a14e7a98aa65a8..7733a762807528 100644 --- a/packages/block-library/src/list-item/edit.js +++ b/packages/block-library/src/list-item/edit.js @@ -36,19 +36,17 @@ import { convertToListItems } from './utils'; export function IndentUI( { clientId } ) { const indentListItem = useIndentListItem( clientId ); const outdentListItem = useOutdentListItem(); - const canIndent = useSelect( - ( select ) => select( blockEditorStore ).getBlockIndex( clientId ) > 0, - [ clientId ] - ); - const canOutdent = useSelect( + const { canIndent, canOutdent } = useSelect( ( select ) => { - const { getBlockRootClientId, getBlockName } = + const { getBlockIndex, getBlockRootClientId, getBlockName } = select( blockEditorStore ); - return ( - getBlockName( - getBlockRootClientId( getBlockRootClientId( clientId ) ) - ) === 'core/list-item' - ); + return { + canIndent: getBlockIndex( clientId ) > 0, + canOutdent: + getBlockName( + getBlockRootClientId( getBlockRootClientId( clientId ) ) + ) === 'core/list-item', + }; }, [ clientId ] );