Skip to content

Commit

Permalink
Remove edit button from zoom out toolbar -- bonus focus loss fix on d…
Browse files Browse the repository at this point in the history
…elete block
  • Loading branch information
jeryj committed Oct 1, 2024
1 parent 26b2205 commit fd9a985
Showing 1 changed file with 2 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* WordPress dependencies
*/
import { dragHandle, trash, edit } from '@wordpress/icons';
import { dragHandle, trash } from '@wordpress/icons';
import { Button, ToolbarButton } from '@wordpress/components';
import { useSelect, useDispatch } from '@wordpress/data';
import { store as blocksStore } from '@wordpress/blocks';
Expand All @@ -15,7 +15,6 @@ import BlockDraggable from '../block-draggable';
import BlockMover from '../block-mover';
import Shuffle from '../block-toolbar/shuffle';
import NavigableToolbar from '../navigable-toolbar';
import { unlock } from '../../lock-unlock';

export default function ZoomOutToolbar( { clientId, __unstableContentRef } ) {
const selected = useSelect(
Expand Down Expand Up @@ -74,12 +73,9 @@ export default function ZoomOutToolbar( { clientId, __unstableContentRef } ) {
isPrevBlockTemplatePart,
canRemove,
canMove,
setIsInserterOpened,
} = selected;

const { removeBlock, __unstableSetEditorMode, resetZoomLevel } = unlock(
useDispatch( blockEditorStore )
);
const { removeBlock } = useDispatch( blockEditorStore );

const showBlockDraggable = canMove && ! isBlockTemplatePart;

Expand Down Expand Up @@ -123,23 +119,6 @@ export default function ZoomOutToolbar( { clientId, __unstableContentRef } ) {
<Shuffle clientId={ clientId } as={ ToolbarButton } />
) }

{ ! isBlockTemplatePart && (
<ToolbarButton
className="zoom-out-toolbar-button"
icon={ edit }
label={ __( 'Edit' ) }
onClick={ () => {
// Setting may be undefined.
if ( typeof setIsInserterOpened === 'function' ) {
setIsInserterOpened( false );
}
__unstableSetEditorMode( 'edit' );
resetZoomLevel();
__unstableContentRef.current?.focus();
} }
/>
) }

{ canRemove && ! isBlockTemplatePart && (
<ToolbarButton
className="zoom-out-toolbar-button"
Expand Down

0 comments on commit fd9a985

Please sign in to comment.