From fe77cd3c7f9df1a5ac0a273097f7eb05282e638e Mon Sep 17 00:00:00 2001 From: Mike Schroder Date: Thu, 1 Jul 2021 22:06:15 +0900 Subject: [PATCH] Block Settings Menu: Disable 'Move to' if there is only one block. --- .../block-settings-menu/block-settings-dropdown.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/block-editor/src/components/block-settings-menu/block-settings-dropdown.js b/packages/block-editor/src/components/block-settings-menu/block-settings-dropdown.js index 28cee8dbe0daa3..74c8cf836fe7e9 100644 --- a/packages/block-editor/src/components/block-settings-menu/block-settings-dropdown.js +++ b/packages/block-editor/src/components/block-settings-menu/block-settings-dropdown.js @@ -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', @@ -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 ); @@ -154,6 +159,7 @@ export function BlockSettingsDropdown( { { ! isLocked && ( { __( 'Move to' ) }