Skip to content

Commit

Permalink
Fix: Remove parent block selector while in Write mode (#67395)
Browse files Browse the repository at this point in the history
Co-authored-by: jorgefilipecosta <jorgefilipecosta@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: richtabor <richtabor@git.wordpress.org>
  • Loading branch information
4 people authored Dec 5, 2024
1 parent f45e35d commit 2caf693
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -24,31 +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' &&
hasBlockSupport(
_parentBlockType,
'__experimentalParentSelector',
true
),
};
}, [] );
const blockInformation = useBlockDisplayInformation( parentClientId );
Expand All @@ -61,10 +47,6 @@ export default function BlockParentSelector() {
highlightParent: true,
} );

if ( ! isVisible ) {
return null;
}

return (
<div
className="block-editor-block-parent-selector"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ export function PrivateBlockToolbar( {
showParentSelector:
! _isZoomOut &&
parentBlockType &&
editingMode !== 'contentOnly' &&
getBlockEditingMode( parentClientId ) !== 'disabled' &&
hasBlockSupport(
parentBlockType,
Expand Down

0 comments on commit 2caf693

Please sign in to comment.