From e21581b38aaaf2f22f44f41a598929a9e5b82ac6 Mon Sep 17 00:00:00 2001 From: Jarda Snajdr Date: Fri, 13 Oct 2023 13:10:43 +0200 Subject: [PATCH] useBlockControlsFill: avoid unneeded store subscriptions (#55340) --- .../block-editor/src/components/block-controls/hook.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/block-editor/src/components/block-controls/hook.js b/packages/block-editor/src/components/block-controls/hook.js index 8f4940a8597dae..18a38e245e58ab 100644 --- a/packages/block-editor/src/components/block-controls/hook.js +++ b/packages/block-editor/src/components/block-controls/hook.js @@ -17,17 +17,20 @@ export default function useBlockControlsFill( group, shareWithChildBlocks ) { const { clientId } = useBlockEditContext(); const isParentDisplayed = useSelect( ( select ) => { + if ( ! shareWithChildBlocks ) { + return false; + } + const { getBlockName, hasSelectedInnerBlock } = select( blockEditorStore ); const { hasBlockSupport } = select( blocksStore ); + return ( - shareWithChildBlocks && hasBlockSupport( getBlockName( clientId ), '__experimentalExposeControlsToChildren', false - ) && - hasSelectedInnerBlock( clientId ) + ) && hasSelectedInnerBlock( clientId ) ); }, [ shareWithChildBlocks, clientId ]