diff --git a/packages/e2e-tests/specs/performance/site-editor.test.js b/packages/e2e-tests/specs/performance/site-editor.test.js index 2e4002bf0bb1c..a14b40d72b01b 100644 --- a/packages/e2e-tests/specs/performance/site-editor.test.js +++ b/packages/e2e-tests/specs/performance/site-editor.test.js @@ -90,7 +90,6 @@ describe( 'Site Editor Performance', () => { await visitSiteEditor( { postId: id, postType: 'page', - path: '/navigation/single', } ); } ); diff --git a/packages/e2e-tests/specs/site-editor/multi-entity-saving.test.js b/packages/e2e-tests/specs/site-editor/multi-entity-saving.test.js index 30b634712119a..fa039fb10fd2e 100644 --- a/packages/e2e-tests/specs/site-editor/multi-entity-saving.test.js +++ b/packages/e2e-tests/specs/site-editor/multi-entity-saving.test.js @@ -265,7 +265,6 @@ describe( 'Multi-entity save flow', () => { await visitSiteEditor( { postId: 'emptytheme//index', postType: 'wp_template', - path: '/templates/single', } ); await enterEditMode(); @@ -305,7 +304,6 @@ describe( 'Multi-entity save flow', () => { await visitSiteEditor( { postId: 'emptytheme//index', postType: 'wp_template', - path: '/templates/single', } ); await enterEditMode(); diff --git a/packages/e2e-tests/specs/site-editor/settings-sidebar.test.js b/packages/e2e-tests/specs/site-editor/settings-sidebar.test.js index c1d4a755a7c57..3428ddd654023 100644 --- a/packages/e2e-tests/specs/site-editor/settings-sidebar.test.js +++ b/packages/e2e-tests/specs/site-editor/settings-sidebar.test.js @@ -69,7 +69,6 @@ describe( 'Settings sidebar', () => { await visitSiteEditor( { postId: 'emptytheme//singular', postType: 'wp_template', - path: '/templates/single', } ); await enterEditMode(); const templateCardAfterNavigation = await getTemplateCard(); diff --git a/packages/edit-site/src/components/add-new-template/new-template-part.js b/packages/edit-site/src/components/add-new-template/new-template-part.js index 1d5a6e08d0c0e..8c3aa84b11974 100644 --- a/packages/edit-site/src/components/add-new-template/new-template-part.js +++ b/packages/edit-site/src/components/add-new-template/new-template-part.js @@ -67,12 +67,9 @@ export default function NewTemplatePart( { setCanvasMode( 'edit' ); // Navigate to the created template part editor. - window.queueMicrotask( () => { - history.push( { - postId: templatePart.id, - postType: 'wp_template_part', - path: '/template-parts/single', - } ); + history.push( { + postId: templatePart.id, + postType: 'wp_template_part', } ); // TODO: Add a success notice? diff --git a/packages/edit-site/src/components/add-new-template/new-template.js b/packages/edit-site/src/components/add-new-template/new-template.js index 6b41c0625a4ca..fb1a6f1fb9f79 100644 --- a/packages/edit-site/src/components/add-new-template/new-template.js +++ b/packages/edit-site/src/components/add-new-template/new-template.js @@ -128,12 +128,9 @@ export default function NewTemplate( { setCanvasMode( 'edit' ); // Navigate to the created template editor. - window.queueMicrotask( () => { - history.push( { - postId: newTemplate.id, - postType: newTemplate.type, - path: '/templates/single', - } ); + history.push( { + postId: newTemplate.id, + postType: newTemplate.type, } ); createSuccessNotice( diff --git a/packages/edit-site/src/components/list/table.js b/packages/edit-site/src/components/list/table.js index 8d561b7e9b818..d6f2405d76b42 100644 --- a/packages/edit-site/src/components/list/table.js +++ b/packages/edit-site/src/components/list/table.js @@ -84,10 +84,6 @@ export default function Table( { templateType } ) { @@ -45,7 +45,7 @@ export default function SidebarNavigationScreenMain() { ) } @@ -53,7 +53,7 @@ export default function SidebarNavigationScreenMain() { diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-navigation-item/index.js b/packages/edit-site/src/components/sidebar-navigation-screen-navigation-item/index.js index 639f6c8ccb83c..f1000fe4a8ee6 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-navigation-item/index.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-navigation-item/index.js @@ -3,7 +3,10 @@ */ import { __ } from '@wordpress/i18n'; import { useDispatch, useSelect } from '@wordpress/data'; -import { Button } from '@wordpress/components'; +import { + Button, + __experimentalUseNavigator as useNavigator, +} from '@wordpress/components'; import { store as coreStore } from '@wordpress/core-data'; import { decodeEntities } from '@wordpress/html-entities'; @@ -16,25 +19,28 @@ import { store as editSiteStore } from '../../store'; export default function SidebarNavigationScreenNavigationItem() { const { setCanvasMode } = unlock( useDispatch( editSiteStore ) ); + const { + params: { postType, postId }, + } = useNavigator(); - const { post } = useSelect( ( select ) => { - const { getEditedPostContext } = select( editSiteStore ); - const { getEntityRecord } = select( coreStore ); - const { postType, postId } = getEditedPostContext() ?? {}; + const { post } = useSelect( + ( select ) => { + const { getEntityRecord } = select( coreStore ); - // The currently selected entity to display. - // Typically template or template part in the site editor. - return { - post: - postId && postType - ? getEntityRecord( 'postType', postType, postId ) - : null, - }; - }, [] ); + // The currently selected entity to display. + // Typically template or template part in the site editor. + return { + post: + postId && postType + ? getEntityRecord( 'postType', postType, postId ) + : null, + }; + }, + [ postType, postId ] + ); return ( diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-template/index.js b/packages/edit-site/src/components/sidebar-navigation-screen-template/index.js index 043cee5dd3f2a..5601b56318ed7 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-template/index.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-template/index.js @@ -13,18 +13,7 @@ import useEditedEntityRecord from '../use-edited-entity-record'; import { unlock } from '../../private-apis'; import { store as editSiteStore } from '../../store'; -const config = { - wp_template: { - path: '/templates/single', - }, - wp_template_part: { - path: '/template-parts/single', - }, -}; - -export default function SidebarNavigationScreenTemplate( { - postType = 'wp_template', -} ) { +export default function SidebarNavigationScreenTemplate() { const { setCanvasMode } = unlock( useDispatch( editSiteStore ) ); const { getDescription, getTitle, record } = useEditedEntityRecord(); let description = getDescription(); @@ -36,7 +25,6 @@ export default function SidebarNavigationScreenTemplate( { return ( - ); +export default function SidebarNavigationScreenTemplatesBrowse() { + const { + params: { postType }, + } = useNavigator(); + return ; } diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-templates/index.js b/packages/edit-site/src/components/sidebar-navigation-screen-templates/index.js index 4c1fd155ac7eb..4a2b8588ee2ae 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-templates/index.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-templates/index.js @@ -4,6 +4,7 @@ import { __experimentalItemGroup as ItemGroup, __experimentalItem as Item, + __experimentalUseNavigator as useNavigator, } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; import { useEntityRecords } from '@wordpress/core-data'; @@ -20,7 +21,6 @@ import AddNewTemplate from '../add-new-template'; const config = { wp_template: { - path: '/templates', labels: { title: __( 'Templates' ), loading: __( 'Loading templates' ), @@ -29,7 +29,6 @@ const config = { }, }, wp_template_part: { - path: '/template-parts', labels: { title: __( 'Template parts' ), loading: __( 'Loading template parts' ), @@ -43,14 +42,14 @@ const TemplateItem = ( { postType, postId, ...props } ) => { const linkInfo = useLink( { postType, postId, - path: config[ postType ].path + '/single', } ); return ; }; -export default function SidebarNavigationScreenTemplates( { - postType = 'wp_template', -} ) { +export default function SidebarNavigationScreenTemplates() { + const { + params: { postType }, + } = useNavigator(); const isMobileViewport = useViewportMatch( 'medium', '<' ); const { records: templates, isResolving: isLoading } = useEntityRecords( @@ -62,14 +61,11 @@ export default function SidebarNavigationScreenTemplates( { ); const browseAllLink = useLink( { - postType, - postId: undefined, - path: config[ postType ].path + '/all', + path: '/' + postType + '/all', } ); return ( - - - { path !== '/' ? ( - - ) : ( -