Skip to content

Commit

Permalink
Adjust after rebase.
Browse files Browse the repository at this point in the history
  • Loading branch information
afercia committed Apr 22, 2024
1 parent e3f79ec commit ce27aeb
Showing 1 changed file with 2 additions and 21 deletions.
23 changes: 2 additions & 21 deletions packages/edit-post/src/components/keyboard-shortcuts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,21 @@
* WordPress dependencies
*/
import { useEffect } from '@wordpress/element';
import { useSelect, useDispatch } from '@wordpress/data';
import { useDispatch } from '@wordpress/data';
import {
useShortcut,
store as keyboardShortcutsStore,
} from '@wordpress/keyboard-shortcuts';
import { __ } from '@wordpress/i18n';
import { store as blockEditorStore } from '@wordpress/block-editor';

/**
* Internal dependencies
*/
import { store as editPostStore } from '../../store';

function KeyboardShortcuts() {
const { isEditorSidebarOpened } = useSelect( editPostStore );
const { openGeneralSidebar, closeGeneralSidebar, toggleFeature } =
useDispatch( editPostStore );
const { toggleFeature } = useDispatch( editPostStore );
const { registerShortcut } = useDispatch( keyboardShortcutsStore );
const { getBlockSelectionStart } = useSelect( blockEditorStore );

useEffect( () => {
registerShortcut( {
Expand Down Expand Up @@ -74,21 +70,6 @@ function KeyboardShortcuts() {
toggleFeature( 'fullscreenMode' );
} );

useShortcut( 'core/edit-post/toggle-sidebar', ( event ) => {
// This shortcut has no known clashes, but use preventDefault to prevent any
// obscure shortcuts from triggering.
event.preventDefault();

if ( isEditorSidebarOpened() ) {
closeGeneralSidebar();
} else {
const sidebarToOpen = getBlockSelectionStart()
? 'edit-post/block'
: 'edit-post/document';
openGeneralSidebar( sidebarToOpen );
}
} );

return null;
}

Expand Down

0 comments on commit ce27aeb

Please sign in to comment.