From ce74764361f1e8d97d898d0f8d8049811175c637 Mon Sep 17 00:00:00 2001 From: Jorge Costa Date: Thu, 28 Nov 2024 14:29:33 +0000 Subject: [PATCH 1/3] Fix: Remove parent block selector while in Write mode --- .../block-editor/src/components/block-parent-selector/index.js | 2 ++ 1 file changed, 2 insertions(+) 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 9090de42f8b7d7..7e0ef10ae21662 100644 --- a/packages/block-editor/src/components/block-parent-selector/index.js +++ b/packages/block-editor/src/components/block-parent-selector/index.js @@ -44,6 +44,8 @@ export default function BlockParentSelector() { isVisible: _parentClientId && getBlockEditingMode( _parentClientId ) !== 'disabled' && + getBlockEditingMode( selectedBlockClientId ) !== + 'contentOnly' && hasBlockSupport( _parentBlockType, '__experimentalParentSelector', From d9fbc25ea816d9d90bcd9b2bde9ce2ff93f57e70 Mon Sep 17 00:00:00 2001 From: Jorge Costa Date: Thu, 5 Dec 2024 16:52:00 +0000 Subject: [PATCH 2/3] Fix: Remove parent block selector while in Write mode --- .../components/block-parent-selector/index.js | 22 +------------------ .../src/components/block-toolbar/index.js | 2 ++ 2 files changed, 3 insertions(+), 21 deletions(-) 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 7e0ef10ae21662..84b5211089cd95 100644 --- a/packages/block-editor/src/components/block-parent-selector/index.js +++ b/packages/block-editor/src/components/block-parent-selector/index.js @@ -1,7 +1,6 @@ /** * WordPress dependencies */ -import { getBlockType, store as blocksStore } from '@wordpress/blocks'; import { ToolbarButton } from '@wordpress/components'; import { useSelect, useDispatch } from '@wordpress/data'; import { __, sprintf } from '@wordpress/i18n'; @@ -24,33 +23,18 @@ import { unlock } from '../../lock-unlock'; */ export default function BlockParentSelector() { const { selectBlock } = useDispatch( blockEditorStore ); - const { parentClientId, isVisible } = useSelect( ( select ) => { + const { parentClientId } = useSelect( ( select ) => { const { - getBlockName, getBlockParents, getSelectedBlockClientId, - getBlockEditingMode, getParentSectionBlock, } = unlock( select( blockEditorStore ) ); - const { hasBlockSupport } = select( blocksStore ); const selectedBlockClientId = getSelectedBlockClientId(); const parentSection = getParentSectionBlock( selectedBlockClientId ); const parents = getBlockParents( selectedBlockClientId ); const _parentClientId = parentSection ?? parents[ parents.length - 1 ]; - const parentBlockName = getBlockName( _parentClientId ); - const _parentBlockType = getBlockType( parentBlockName ); return { parentClientId: _parentClientId, - isVisible: - _parentClientId && - getBlockEditingMode( _parentClientId ) !== 'disabled' && - getBlockEditingMode( selectedBlockClientId ) !== - 'contentOnly' && - hasBlockSupport( - _parentBlockType, - '__experimentalParentSelector', - true - ), }; }, [] ); const blockInformation = useBlockDisplayInformation( parentClientId ); @@ -63,10 +47,6 @@ export default function BlockParentSelector() { highlightParent: true, } ); - if ( ! isVisible ) { - return null; - } - return (
Date: Thu, 5 Dec 2024 21:23:13 +0400 Subject: [PATCH 3/3] Reuse editingMode --- packages/block-editor/src/components/block-toolbar/index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/block-editor/src/components/block-toolbar/index.js b/packages/block-editor/src/components/block-toolbar/index.js index e46b2f412a21ac..083d77a694a7b2 100644 --- a/packages/block-editor/src/components/block-toolbar/index.js +++ b/packages/block-editor/src/components/block-toolbar/index.js @@ -136,9 +136,8 @@ export function PrivateBlockToolbar( { showParentSelector: ! _isZoomOut && parentBlockType && + editingMode !== 'contentOnly' && getBlockEditingMode( parentClientId ) !== 'disabled' && - getBlockEditingMode( selectedBlockClientId ) !== - 'contentOnly' && hasBlockSupport( parentBlockType, '__experimentalParentSelector',