Skip to content

Commit

Permalink
Block Settings Menu: Disable 'Move to' if there is only one block.
Browse files Browse the repository at this point in the history
  • Loading branch information
getsource authored and jorgefilipecosta committed Jul 1, 2021
1 parent bd97818 commit fe77cd3
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import BlockModeToggle from './block-mode-toggle';
import BlockHTMLConvertButton from './block-html-convert-button';
import __unstableBlockSettingsMenuFirstItem from './block-settings-menu-first-item';
import BlockSettingsMenuControls from '../block-settings-menu-controls';
import { store as blockEditorStore } from '../../store';

const POPOVER_PROPS = {
className: 'block-editor-block-settings-menu__popover',
Expand All @@ -45,6 +46,10 @@ export function BlockSettingsDropdown( {
const blockClientIds = castArray( clientIds );
const count = blockClientIds.length;
const firstBlockClientId = blockClientIds[ 0 ];
const onlyBlock = useSelect(
( select ) => 1 === select( blockEditorStore ).getBlockCount(),
[]
);

const shortcuts = useSelect( ( select ) => {
const { getShortcutRepresentation } = select( keyboardShortcutsStore );
Expand Down Expand Up @@ -154,6 +159,7 @@ export function BlockSettingsDropdown( {
{ ! isLocked && (
<MenuItem
onClick={ flow( onClose, onMoveTo ) }
disabled={ onlyBlock }
>
{ __( 'Move to' ) }
</MenuItem>
Expand Down

0 comments on commit fe77cd3

Please sign in to comment.