diff --git a/packages/block-editor/src/components/block-parent-selector/index.js b/packages/block-editor/src/components/block-parent-selector/index.js index e47295e449899..178dcef290faa 100644 --- a/packages/block-editor/src/components/block-parent-selector/index.js +++ b/packages/block-editor/src/components/block-parent-selector/index.js @@ -19,23 +19,33 @@ import BlockIcon from '../block-icon'; */ export default function BlockParentSelector() { const { selectBlock } = useDispatch( 'core/block-editor' ); - const { parentBlockType, firstParentClientId } = useSelect( ( select ) => { - const { - getBlockName, - getBlockParents, - getSelectedBlockClientId, - } = select( 'core/block-editor' ); - const selectedBlockClientId = getSelectedBlockClientId(); - const parents = getBlockParents( selectedBlockClientId ); - const _firstParentClientId = parents[ parents.length - 1 ]; - const parentBlockName = getBlockName( _firstParentClientId ); - return { - parentBlockType: getBlockType( parentBlockName ), - firstParentClientId: _firstParentClientId, - }; - }, [] ); + const { parentBlockType, firstParentClientId, shouldHide } = useSelect( + ( select ) => { + const { + getBlockName, + getBlockParents, + getSelectedBlockClientId, + } = select( 'core/block-editor' ); + const { hasBlockSupport } = select( 'core/blocks' ); + const selectedBlockClientId = getSelectedBlockClientId(); + const parents = getBlockParents( selectedBlockClientId ); + const _firstParentClientId = parents[ parents.length - 1 ]; + const parentBlockName = getBlockName( _firstParentClientId ); + const _parentBlockType = getBlockType( parentBlockName ); + return { + parentBlockType: _parentBlockType, + firstParentClientId: _firstParentClientId, + shouldHide: ! hasBlockSupport( + parentBlockType, + '__experimentalParentSelector', + true + ), + }; + }, + [] + ); - if ( parentBlockType.hideParentSelector ) { + if ( shouldHide ) { return null; } diff --git a/packages/edit-widgets/src/blocks/widget-area/index.js b/packages/edit-widgets/src/blocks/widget-area/index.js index 3902b79380930..f62dedda3c5e5 100644 --- a/packages/edit-widgets/src/blocks/widget-area/index.js +++ b/packages/edit-widgets/src/blocks/widget-area/index.js @@ -16,6 +16,9 @@ export const settings = { title: __( 'Widget Area' ), description: __( 'A widget area container.' ), __experimentalLabel: ( { name: label } ) => label, - hideParentSelector: true, + supports: { + // Should show the parent selector for its children or not. Defaults to true. + __experimentalParentSelector: false, + }, edit, };