Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Use MenuSwitcher
  • Loading branch information
Mamaduka committed Sep 14, 2021
commit e33412f8f93f1a221046b9a04975149c9d02f700
31 changes: 10 additions & 21 deletions packages/edit-navigation/src/components/header/actions.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
/**
* WordPress dependencies
*/
import { sprintf, __ } from '@wordpress/i18n';
import { __ } from '@wordpress/i18n';
import {
DropdownMenu,
MenuGroup,
MenuItemsChoice,
__experimentalText as Text,
} from '@wordpress/components';
import { chevronDown } from '@wordpress/icons';
Expand All @@ -15,6 +13,7 @@ import { decodeEntities } from '@wordpress/html-entities';
/**
* Internal dependencies
*/
import MenuSwitcher from '../menu-switcher';
import { useMenuEntityProp, useSelectedMenuId } from '../../hooks';

export default function HeaderActions( { menus, isLoading } ) {
Expand Down Expand Up @@ -65,24 +64,14 @@ export default function HeaderActions( { menus, isLoading } ) {
} }
>
{ ( { onClose } ) => (
<MenuGroup>
<MenuItemsChoice
value={ selectedMenuId }
choices={ menus.map( ( { id, name } ) => ( {
value: id,
label: decodeEntities( name ),
'aria-label': sprintf(
/* translators: %s: The name of a menu. */
__( "Switch to '%s'" ),
name
),
} ) ) }
onSelect={ ( value ) => {
setSelectedMenuId( value );
onClose();
} }
/>
</MenuGroup>
<MenuSwitcher
menus={ menus }
selectedMenuId={ selectedMenuId }
onSelectMenu={ ( menuId ) => {
setSelectedMenuId( menuId );
onClose();
} }
/>
) }
</DropdownMenu>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ export default function MenuSwitcher( {
/>
</MenuGroup>
<MenuGroup hideSeparator>
<MenuItem variant="primary" onClick={ openModal }>
<MenuItem
className="edit-navigation-menu-switcher__new-button"
onClick={ openModal }
>
{ __( 'Create a new menu' ) }
</MenuItem>
{ isModalVisible && (
Expand Down