Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Block Settings Menu: Disable 'Move to' if there is only one block. #33135

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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