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

Disable navigation block for text mode. #12185

Merged
merged 8 commits into from
Feb 5, 2019
8 changes: 5 additions & 3 deletions packages/editor/src/components/block-navigation/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,26 @@ const MenuIcon = (
</SVG>
);

function BlockNavigationDropdown( { hasBlocks } ) {
function BlockNavigationDropdown( { hasBlocks, isTextModeEnabled } ) {
return (
<Dropdown
renderToggle={ ( { isOpen, onToggle } ) => (
<Fragment>
<KeyboardShortcuts
{ hasBlocks && ! isTextModeEnabled && <KeyboardShortcuts
bindGlobal
shortcuts={ {
[ rawShortcut.access( 'o' ) ]: onToggle,
} }
/>
}
<IconButton
icon={ MenuIcon }
aria-expanded={ isOpen }
onClick={ hasBlocks ? onToggle : undefined }
label={ __( 'Block Navigation' ) }
className="editor-block-navigation"
shortcut={ displayShortcut.access( 'o' ) }
aria-disabled={ ! hasBlocks }
disabled={ ! hasBlocks || isTextModeEnabled }
/>
</Fragment>
) }
Expand All @@ -50,5 +51,6 @@ function BlockNavigationDropdown( { hasBlocks } ) {
export default withSelect( ( select ) => {
return {
hasBlocks: !! select( 'core/editor' ).getBlockCount(),
isTextModeEnabled: select( 'core/edit-post' ).getEditorMode() === 'text',
};
} )( BlockNavigationDropdown );