Skip to content

Commit

Permalink
Disable navigation block for text mode. (#12185)
Browse files Browse the repository at this point in the history
* Disable navigation block for text mode.

* Add additional rule for disabling navigation blocks.

* Disable click handler for required rules.

* Adjusted click handler for for text mode.

* Disabled keyboard shortcut in text mode.

* Deleted obsolete onClick check.
  • Loading branch information
nicolad authored and youknowriad committed Mar 6, 2019
1 parent 9169ed1 commit 1a77b44
Showing 1 changed file with 5 additions and 3 deletions.
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 );

0 comments on commit 1a77b44

Please sign in to comment.