Skip to content

Commit

Permalink
Remove default entry into Navigation Menu focus mode but retain abili…
Browse files Browse the repository at this point in the history
…ty to access via "Edit" (#61275)

* Add new route for single Navigation without navigating to focus mode

* Add edit option to Navigation Menu to enter focus mode

* Amend back route from single Nav Menu to Nav Listing

Co-authored-by: getdave <get_dave@git.wordpress.org>
Co-authored-by: draganescu <andraganescu@git.wordpress.org>
Co-authored-by: fabiankaegy <fabiankaegy@git.wordpress.org>
Co-authored-by: jeryj <jeryj@git.wordpress.org>
  • Loading branch information
5 people authored May 3, 2024
1 parent dde38de commit f9908e5
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 3 deletions.
14 changes: 13 additions & 1 deletion packages/edit-site/src/components/layout/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,20 @@ export default function useLayoutAreas() {

// Navigation
if ( path === '/navigation' ) {
if ( postId ) {
return {
key: 'navigation',
areas: {
sidebar: <SidebarNavigationScreenNavigationMenu />,
preview: <Editor isLoading={ isSiteEditorLoading } />,
mobile: canvas === 'edit' && (
<Editor isLoading={ isSiteEditorLoading } />
),
},
};
}
return {
key: 'styles',
key: 'navigation',
areas: {
sidebar: <SidebarNavigationScreenNavigationMenus />,
preview: <Editor isLoading={ isSiteEditorLoading } />,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export default function SidebarNavigationScreenNavigationMenu() {
<SidebarNavigationScreenWrapper
actions={
<ScreenNavigationMoreMenu
menuId={ navigationMenu?.id }
menuTitle={ decodeEntities( menuTitle ) }
onDelete={ _handleDelete }
onSave={ _handleSave }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,30 @@ import { DropdownMenu, MenuItem, MenuGroup } from '@wordpress/components';
import { moreVertical } from '@wordpress/icons';
import { __ } from '@wordpress/i18n';
import { useState } from '@wordpress/element';
import { privateApis as routerPrivateApis } from '@wordpress/router';

/**
* Internal dependencies
*/
import RenameModal from './rename-modal';
import DeleteConfirmDialog from './delete-confirm-dialog';
import { unlock } from '../../lock-unlock';

const { useHistory } = unlock( routerPrivateApis );

const POPOVER_PROPS = {
position: 'bottom right',
};

export default function ScreenNavigationMoreMenu( props ) {
const { onDelete, onSave, onDuplicate, menuTitle } = props;
const { onDelete, onSave, onDuplicate, menuTitle, menuId } = props;

const [ renameModalOpen, setRenameModalOpen ] = useState( false );
const [ deleteConfirmDialogOpen, setDeleteConfirmDialogOpen ] =
useState( false );

const history = useHistory();

const closeModals = () => {
setRenameModalOpen( false );
setDeleteConfirmDialogOpen( false );
Expand Down Expand Up @@ -50,6 +56,17 @@ export default function ScreenNavigationMoreMenu( props ) {
>
{ __( 'Rename' ) }
</MenuItem>
<MenuItem
onClick={ () => {
history.push( {
postId: menuId,
postType: 'wp_navigation',
canvas: 'edit',
} );
} }
>
{ __( 'Edit' ) }
</MenuItem>
<MenuItem
onClick={ () => {
onDuplicate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default function SingleNavigationMenu( {
actions={
<>
<ScreenNavigationMoreMenu
menuId={ navigationMenu?.id }
menuTitle={ decodeEntities( menuTitle ) }
onDelete={ handleDelete }
onSave={ handleSave }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export function SidebarNavigationScreenWrapper( {
const NavMenuItem = ( { postId, ...props } ) => {
const linkInfo = useLink( {
postId,
postType: NAVIGATION_POST_TYPE,
path: '/navigation',
} );
return <SidebarNavigationItem { ...linkInfo } { ...props } />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ import { SidebarNavigationContext } from '../sidebar';
const { useHistory, useLocation } = unlock( routerPrivateApis );

function getBackPath( params ) {
// Navigation Menus are not currently part of a data view.
// Therefore when navigating back from a navigation menu
// the target path is the navigation listing view.
if ( params.path === '/navigation' && params.postId ) {
return { path: '/navigation' };
}

// From a data view path we navigate back to root
if ( params.path ) {
return {};
Expand Down

0 comments on commit f9908e5

Please sign in to comment.