Skip to content

Commit

Permalink
Show Block Inspector when menu name is clicked.
Browse files Browse the repository at this point in the history
  • Loading branch information
getsource committed May 12, 2021
1 parent 146f617 commit 2ed1104
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions packages/edit-navigation/src/components/name-display/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
import { useContext } from '@wordpress/element';
import { ToolbarGroup, ToolbarButton } from '@wordpress/components';
import { BlockControls } from '@wordpress/block-editor';
import { useDispatch } from '@wordpress/data';
import { store as interfaceStore } from '@wordpress/interface';
import { sprintf, __ } from '@wordpress/i18n';

/**
* Internal dependencies
*/
Expand All @@ -13,9 +17,13 @@ import {
useMenuEntityProp,
IsMenuNameControlFocusedContext,
} from '../../hooks';
import {
COMPLEMENTARY_AREA_SCOPE,
COMPLEMENTARY_AREA_ID,
} from '../../constants';

import { sprintf, __ } from '@wordpress/i18n';
export default function NameDisplay() {
const { enableComplementaryArea } = useDispatch( interfaceStore );
const [ menuId ] = useSelectedMenuId();
const [ name ] = useMenuEntityProp( 'name', menuId );
const [ , setIsMenuNameEditFocused ] = useContext(
Expand All @@ -33,7 +41,13 @@ export default function NameDisplay() {
__( `Edit menu name: %s` ),
menuName
) }
onClick={ () => setIsMenuNameEditFocused( true ) }
onClick={ () => {
enableComplementaryArea(
COMPLEMENTARY_AREA_SCOPE,
COMPLEMENTARY_AREA_ID
);
setIsMenuNameEditFocused( true );
} }
>
{ menuName }
</ToolbarButton>
Expand Down

0 comments on commit 2ed1104

Please sign in to comment.