Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove default entry into Navigation Menu focus mode but retain ability to access via "Edit" #61275

Merged
merged 3 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
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',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was going on here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo from someone I expect. I've seen in corrected in other (yet to be merged) PRs.

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
Loading