@wordpress/edit-site 5.3.3 → 5.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/build/components/add-new-template/new-template-part.js +3 -6
  2. package/build/components/add-new-template/new-template-part.js.map +1 -1
  3. package/build/components/add-new-template/new-template.js +3 -6
  4. package/build/components/add-new-template/new-template.js.map +1 -1
  5. package/build/components/global-styles/screen-border.js +1 -1
  6. package/build/components/global-styles/screen-border.js.map +1 -1
  7. package/build/components/global-styles/ui.js +1 -1
  8. package/build/components/global-styles/ui.js.map +1 -1
  9. package/build/components/list/table.js +0 -1
  10. package/build/components/list/table.js.map +1 -1
  11. package/build/components/navigation-inspector/navigation-menu.js +4 -2
  12. package/build/components/navigation-inspector/navigation-menu.js.map +1 -1
  13. package/build/components/save-panel/index.js +11 -1
  14. package/build/components/save-panel/index.js.map +1 -1
  15. package/build/components/sidebar/index.js +14 -33
  16. package/build/components/sidebar/index.js.map +1 -1
  17. package/build/components/sidebar-edit-mode/global-styles-sidebar.js +8 -2
  18. package/build/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -1
  19. package/build/components/sidebar-navigation-screen/index.js +4 -7
  20. package/build/components/sidebar-navigation-screen/index.js.map +1 -1
  21. package/build/components/sidebar-navigation-screen-main/index.js +3 -3
  22. package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
  23. package/build/components/sidebar-navigation-screen-navigation-item/index.js +8 -12
  24. package/build/components/sidebar-navigation-screen-navigation-item/index.js.map +1 -1
  25. package/build/components/sidebar-navigation-screen-navigation-menus/index.js +1 -3
  26. package/build/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
  27. package/build/components/sidebar-navigation-screen-template/index.js +1 -14
  28. package/build/components/sidebar-navigation-screen-template/index.js.map +1 -1
  29. package/build/components/sidebar-navigation-screen-templates/index.js +8 -12
  30. package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -1
  31. package/build/components/sidebar-navigation-screen-templates-browse/index.js +8 -7
  32. package/build/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
  33. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +34 -32
  34. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
  35. package/build/components/sync-state-with-url/use-sync-path-with-url.js +67 -18
  36. package/build/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
  37. package/build/utils/get-is-list-page.js +1 -1
  38. package/build/utils/get-is-list-page.js.map +1 -1
  39. package/build-module/components/add-new-template/new-template-part.js +3 -6
  40. package/build-module/components/add-new-template/new-template-part.js.map +1 -1
  41. package/build-module/components/add-new-template/new-template.js +3 -6
  42. package/build-module/components/add-new-template/new-template.js.map +1 -1
  43. package/build-module/components/global-styles/screen-border.js +1 -1
  44. package/build-module/components/global-styles/screen-border.js.map +1 -1
  45. package/build-module/components/global-styles/ui.js +1 -1
  46. package/build-module/components/global-styles/ui.js.map +1 -1
  47. package/build-module/components/list/table.js +0 -1
  48. package/build-module/components/list/table.js.map +1 -1
  49. package/build-module/components/navigation-inspector/navigation-menu.js +4 -2
  50. package/build-module/components/navigation-inspector/navigation-menu.js.map +1 -1
  51. package/build-module/components/save-panel/index.js +8 -1
  52. package/build-module/components/save-panel/index.js.map +1 -1
  53. package/build-module/components/sidebar/index.js +15 -32
  54. package/build-module/components/sidebar/index.js.map +1 -1
  55. package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js +8 -2
  56. package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -1
  57. package/build-module/components/sidebar-navigation-screen/index.js +5 -8
  58. package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
  59. package/build-module/components/sidebar-navigation-screen-main/index.js +3 -3
  60. package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
  61. package/build-module/components/sidebar-navigation-screen-navigation-item/index.js +9 -13
  62. package/build-module/components/sidebar-navigation-screen-navigation-item/index.js.map +1 -1
  63. package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js +1 -3
  64. package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
  65. package/build-module/components/sidebar-navigation-screen-template/index.js +1 -13
  66. package/build-module/components/sidebar-navigation-screen-template/index.js.map +1 -1
  67. package/build-module/components/sidebar-navigation-screen-templates/index.js +9 -13
  68. package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -1
  69. package/build-module/components/sidebar-navigation-screen-templates-browse/index.js +7 -7
  70. package/build-module/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
  71. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +34 -32
  72. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
  73. package/build-module/components/sync-state-with-url/use-sync-path-with-url.js +67 -18
  74. package/build-module/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
  75. package/build-module/utils/get-is-list-page.js +1 -1
  76. package/build-module/utils/get-is-list-page.js.map +1 -1
  77. package/build-style/style-rtl.css +19 -9
  78. package/build-style/style.css +19 -9
  79. package/package.json +21 -21
  80. package/src/components/add-new-template/new-template-part.js +3 -6
  81. package/src/components/add-new-template/new-template.js +3 -6
  82. package/src/components/editor/style.scss +0 -6
  83. package/src/components/global-styles/screen-border.js +1 -1
  84. package/src/components/global-styles/ui.js +1 -1
  85. package/src/components/layout/style.scss +8 -1
  86. package/src/components/list/table.js +0 -4
  87. package/src/components/navigation-inspector/navigation-menu.js +8 -2
  88. package/src/components/save-panel/index.js +8 -1
  89. package/src/components/sidebar/index.js +26 -27
  90. package/src/components/sidebar-edit-mode/global-styles-sidebar.js +3 -7
  91. package/src/components/sidebar-edit-mode/style.scss +16 -0
  92. package/src/components/sidebar-navigation-screen/index.js +31 -37
  93. package/src/components/sidebar-navigation-screen/style.scss +1 -0
  94. package/src/components/sidebar-navigation-screen-main/index.js +3 -3
  95. package/src/components/sidebar-navigation-screen-navigation-item/index.js +21 -15
  96. package/src/components/sidebar-navigation-screen-navigation-menus/index.js +0 -2
  97. package/src/components/sidebar-navigation-screen-template/index.js +1 -13
  98. package/src/components/sidebar-navigation-screen-templates/index.js +6 -10
  99. package/src/components/sidebar-navigation-screen-templates-browse/index.js +6 -11
  100. package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +31 -22
  101. package/src/components/sync-state-with-url/use-sync-path-with-url.js +78 -17
  102. package/src/utils/get-is-list-page.js +1 -1
@@ -6,7 +6,6 @@ import {
6
6
  __experimentalVStack as VStack,
7
7
  __experimentalNavigatorToParentButton as NavigatorToParentButton,
8
8
  Button,
9
- __experimentalNavigatorScreen as NavigatorScreen,
10
9
  } from '@wordpress/components';
11
10
  import { isRTL, __ } from '@wordpress/i18n';
12
11
  import { chevronRight, chevronLeft } from '@wordpress/icons';
@@ -19,7 +18,7 @@ import { store as editSiteStore } from '../../store';
19
18
  import { unlock } from '../../private-apis';
20
19
 
21
20
  export default function SidebarNavigationScreen( {
22
- path,
21
+ isRoot,
23
22
  title,
24
23
  actions,
25
24
  content,
@@ -32,41 +31,36 @@ export default function SidebarNavigationScreen( {
32
31
  }, [] );
33
32
 
34
33
  return (
35
- <NavigatorScreen
36
- className="edit-site-sidebar-navigation-screen"
37
- path={ path }
38
- >
39
- <VStack spacing={ 2 }>
40
- <HStack
41
- spacing={ 4 }
42
- justify="flex-start"
43
- className="edit-site-sidebar-navigation-screen__title-icon"
44
- >
45
- { path !== '/' ? (
46
- <NavigatorToParentButton
47
- className="edit-site-sidebar-navigation-screen__back"
48
- icon={ isRTL() ? chevronRight : chevronLeft }
49
- aria-label={ __( 'Back' ) }
50
- />
51
- ) : (
52
- <Button
53
- className="edit-site-sidebar-navigation-screen__back"
54
- icon={ isRTL() ? chevronRight : chevronLeft }
55
- aria-label={ __( 'Navigate to the Dashboard' ) }
56
- href={ dashboardLink || 'index.php' }
57
- label={ __( 'Dashboard' ) }
58
- />
59
- ) }
60
- <h2 className="edit-site-sidebar-navigation-screen__title">
61
- { title }
62
- </h2>
63
- { actions }
64
- </HStack>
34
+ <VStack spacing={ 2 }>
35
+ <HStack
36
+ spacing={ 4 }
37
+ justify="flex-start"
38
+ className="edit-site-sidebar-navigation-screen__title-icon"
39
+ >
40
+ { ! isRoot ? (
41
+ <NavigatorToParentButton
42
+ className="edit-site-sidebar-navigation-screen__back"
43
+ icon={ isRTL() ? chevronRight : chevronLeft }
44
+ aria-label={ __( 'Back' ) }
45
+ />
46
+ ) : (
47
+ <Button
48
+ className="edit-site-sidebar-navigation-screen__back"
49
+ icon={ isRTL() ? chevronRight : chevronLeft }
50
+ aria-label={ __( 'Navigate to the Dashboard' ) }
51
+ href={ dashboardLink || 'index.php' }
52
+ label={ __( 'Dashboard' ) }
53
+ />
54
+ ) }
55
+ <h2 className="edit-site-sidebar-navigation-screen__title">
56
+ { title }
57
+ </h2>
58
+ { actions }
59
+ </HStack>
65
60
 
66
- <nav className="edit-site-sidebar-navigation-screen__content">
67
- { content }
68
- </nav>
69
- </VStack>
70
- </NavigatorScreen>
61
+ <nav className="edit-site-sidebar-navigation-screen__content">
62
+ { content }
63
+ </nav>
64
+ </VStack>
71
65
  );
72
66
  }
@@ -33,6 +33,7 @@
33
33
  color: $gray-200;
34
34
 
35
35
  &:hover,
36
+ &:focus,
36
37
  &:not([aria-disabled="true"]):active {
37
38
  color: $white;
38
39
  }
@@ -29,7 +29,7 @@ export default function SidebarNavigationScreenMain() {
29
29
 
30
30
  return (
31
31
  <SidebarNavigationScreen
32
- path="/"
32
+ isRoot
33
33
  title={ __( 'Design' ) }
34
34
  content={
35
35
  <ItemGroup>
@@ -45,7 +45,7 @@ export default function SidebarNavigationScreenMain() {
45
45
  ) }
46
46
  <NavigatorButton
47
47
  as={ SidebarNavigationItem }
48
- path="/templates"
48
+ path="/wp_template"
49
49
  withChevron
50
50
  icon={ layout }
51
51
  >
@@ -53,7 +53,7 @@ export default function SidebarNavigationScreenMain() {
53
53
  </NavigatorButton>
54
54
  <NavigatorButton
55
55
  as={ SidebarNavigationItem }
56
- path="/template-parts"
56
+ path="/wp_template_part"
57
57
  withChevron
58
58
  icon={ symbolFilled }
59
59
  >
@@ -3,7 +3,10 @@
3
3
  */
4
4
  import { __ } from '@wordpress/i18n';
5
5
  import { useDispatch, useSelect } from '@wordpress/data';
6
- import { Button } from '@wordpress/components';
6
+ import {
7
+ Button,
8
+ __experimentalUseNavigator as useNavigator,
9
+ } from '@wordpress/components';
7
10
  import { store as coreStore } from '@wordpress/core-data';
8
11
  import { decodeEntities } from '@wordpress/html-entities';
9
12
 
@@ -16,25 +19,28 @@ import { store as editSiteStore } from '../../store';
16
19
 
17
20
  export default function SidebarNavigationScreenNavigationItem() {
18
21
  const { setCanvasMode } = unlock( useDispatch( editSiteStore ) );
22
+ const {
23
+ params: { postType, postId },
24
+ } = useNavigator();
19
25
 
20
- const { post } = useSelect( ( select ) => {
21
- const { getEditedPostContext } = select( editSiteStore );
22
- const { getEntityRecord } = select( coreStore );
23
- const { postType, postId } = getEditedPostContext() ?? {};
26
+ const { post } = useSelect(
27
+ ( select ) => {
28
+ const { getEntityRecord } = select( coreStore );
24
29
 
25
- // The currently selected entity to display.
26
- // Typically template or template part in the site editor.
27
- return {
28
- post:
29
- postId && postType
30
- ? getEntityRecord( 'postType', postType, postId )
31
- : null,
32
- };
33
- }, [] );
30
+ // The currently selected entity to display.
31
+ // Typically template or template part in the site editor.
32
+ return {
33
+ post:
34
+ postId && postType
35
+ ? getEntityRecord( 'postType', postType, postId )
36
+ : null,
37
+ };
38
+ },
39
+ [ postType, postId ]
40
+ );
34
41
 
35
42
  return (
36
43
  <SidebarNavigationScreen
37
- path="/navigation/single"
38
44
  title={ post ? decodeEntities( post?.title?.rendered ) : null }
39
45
  actions={
40
46
  <Button
@@ -25,7 +25,6 @@ export default function SidebarNavigationScreenNavigationMenus() {
25
25
  history.push( {
26
26
  postType: attributes.type,
27
27
  postId: attributes.id,
28
- path: '/navigation/single',
29
28
  } );
30
29
  }
31
30
  },
@@ -33,7 +32,6 @@ export default function SidebarNavigationScreenNavigationMenus() {
33
32
  );
34
33
  return (
35
34
  <SidebarNavigationScreen
36
- path="/navigation"
37
35
  title={ __( 'Navigation' ) }
38
36
  content={
39
37
  <div className="edit-site-sidebar-navigation-screen-navigation-menus">
@@ -13,18 +13,7 @@ import useEditedEntityRecord from '../use-edited-entity-record';
13
13
  import { unlock } from '../../private-apis';
14
14
  import { store as editSiteStore } from '../../store';
15
15
 
16
- const config = {
17
- wp_template: {
18
- path: '/templates/single',
19
- },
20
- wp_template_part: {
21
- path: '/template-parts/single',
22
- },
23
- };
24
-
25
- export default function SidebarNavigationScreenTemplate( {
26
- postType = 'wp_template',
27
- } ) {
16
+ export default function SidebarNavigationScreenTemplate() {
28
17
  const { setCanvasMode } = unlock( useDispatch( editSiteStore ) );
29
18
  const { getDescription, getTitle, record } = useEditedEntityRecord();
30
19
  let description = getDescription();
@@ -36,7 +25,6 @@ export default function SidebarNavigationScreenTemplate( {
36
25
 
37
26
  return (
38
27
  <SidebarNavigationScreen
39
- path={ config[ postType ].path }
40
28
  title={ getTitle() }
41
29
  actions={
42
30
  <Button
@@ -4,6 +4,7 @@
4
4
  import {
5
5
  __experimentalItemGroup as ItemGroup,
6
6
  __experimentalItem as Item,
7
+ __experimentalUseNavigator as useNavigator,
7
8
  } from '@wordpress/components';
8
9
  import { __ } from '@wordpress/i18n';
9
10
  import { useEntityRecords } from '@wordpress/core-data';
@@ -20,7 +21,6 @@ import AddNewTemplate from '../add-new-template';
20
21
 
21
22
  const config = {
22
23
  wp_template: {
23
- path: '/templates',
24
24
  labels: {
25
25
  title: __( 'Templates' ),
26
26
  loading: __( 'Loading templates' ),
@@ -29,7 +29,6 @@ const config = {
29
29
  },
30
30
  },
31
31
  wp_template_part: {
32
- path: '/template-parts',
33
32
  labels: {
34
33
  title: __( 'Template parts' ),
35
34
  loading: __( 'Loading template parts' ),
@@ -43,14 +42,14 @@ const TemplateItem = ( { postType, postId, ...props } ) => {
43
42
  const linkInfo = useLink( {
44
43
  postType,
45
44
  postId,
46
- path: config[ postType ].path + '/single',
47
45
  } );
48
46
  return <SidebarNavigationItem { ...linkInfo } { ...props } />;
49
47
  };
50
48
 
51
- export default function SidebarNavigationScreenTemplates( {
52
- postType = 'wp_template',
53
- } ) {
49
+ export default function SidebarNavigationScreenTemplates() {
50
+ const {
51
+ params: { postType },
52
+ } = useNavigator();
54
53
  const isMobileViewport = useViewportMatch( 'medium', '<' );
55
54
 
56
55
  const { records: templates, isResolving: isLoading } = useEntityRecords(
@@ -62,14 +61,11 @@ export default function SidebarNavigationScreenTemplates( {
62
61
  );
63
62
 
64
63
  const browseAllLink = useLink( {
65
- postType,
66
- postId: undefined,
67
- path: config[ postType ].path + '/all',
64
+ path: '/' + postType + '/all',
68
65
  } );
69
66
 
70
67
  return (
71
68
  <SidebarNavigationScreen
72
- path={ config[ postType ].path }
73
69
  title={ config[ postType ].labels.title }
74
70
  actions={
75
71
  ! isMobileViewport && (
@@ -2,6 +2,7 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { __ } from '@wordpress/i18n';
5
+ import { __experimentalUseNavigator as useNavigator } from '@wordpress/components';
5
6
 
6
7
  /**
7
8
  * Internal dependencies
@@ -10,22 +11,16 @@ import SidebarNavigationScreen from '../sidebar-navigation-screen';
10
11
 
11
12
  const config = {
12
13
  wp_template: {
13
- path: '/templates/all',
14
14
  title: __( 'All templates' ),
15
15
  },
16
16
  wp_template_part: {
17
- path: '/template-parts/all',
18
17
  title: __( 'All template parts' ),
19
18
  },
20
19
  };
21
20
 
22
- export default function SidebarNavigationScreenTemplatesBrowse( {
23
- postType = 'wp_template',
24
- } ) {
25
- return (
26
- <SidebarNavigationScreen
27
- path={ config[ postType ].path }
28
- title={ config[ postType ].title }
29
- />
30
- );
21
+ export default function SidebarNavigationScreenTemplatesBrowse() {
22
+ const {
23
+ params: { postType },
24
+ } = useNavigator();
25
+ return <SidebarNavigationScreen title={ config[ postType ].title } />;
31
26
  }
@@ -12,7 +12,7 @@ import { useLocation } from '../routes';
12
12
  import { store as editSiteStore } from '../../store';
13
13
 
14
14
  export default function useInitEditedEntityFromURL() {
15
- const { params: { postId, postType, path = '/' } = {} } = useLocation();
15
+ const { params: { postId, postType } = {} } = useLocation();
16
16
  const { isRequestingSite, homepageId } = useSelect( ( select ) => {
17
17
  const { getSite } = select( coreDataStore );
18
18
  const siteData = getSite();
@@ -30,33 +30,42 @@ export default function useInitEditedEntityFromURL() {
30
30
  useDispatch( editSiteStore );
31
31
 
32
32
  useEffect( () => {
33
- switch ( path ) {
34
- case '/templates/single':
35
- setTemplate( postId );
36
- break;
37
- case '/template-parts/single':
38
- setTemplatePart( postId );
39
- break;
40
- case '/navigation/single':
41
- setPage( {
42
- context: { postType, postId },
43
- } );
44
- break;
45
- default: {
46
- if ( homepageId ) {
33
+ if (
34
+ postType &&
35
+ postId &&
36
+ // This is just a special case to support old WP versions that perform redirects.
37
+ // This code should be removed when we minimum WP version becomes 6.2.
38
+ postId !== 'none'
39
+ ) {
40
+ switch ( postType ) {
41
+ case 'wp_template':
42
+ setTemplate( postId );
43
+ break;
44
+ case 'wp_template_part':
45
+ setTemplatePart( postId );
46
+ break;
47
+ default:
47
48
  setPage( {
48
- context: { postType: 'page', postId: homepageId },
49
+ context: { postType, postId },
49
50
  } );
50
- } else if ( ! isRequestingSite ) {
51
- setPage( {
52
- path: '/',
53
- } );
54
- }
55
51
  }
52
+
53
+ return;
54
+ }
55
+
56
+ // In all other cases, we need to set the home page in the site editor view.
57
+ if ( homepageId ) {
58
+ setPage( {
59
+ context: { postType: 'page', postId: homepageId },
60
+ } );
61
+ } else if ( ! isRequestingSite ) {
62
+ setPage( {
63
+ path: '/',
64
+ } );
56
65
  }
57
66
  }, [
58
- path,
59
67
  postId,
68
+ postType,
60
69
  homepageId,
61
70
  isRequestingSite,
62
71
  setPage,
@@ -11,26 +11,87 @@ import { useLocation, useHistory } from '../routes';
11
11
 
12
12
  export default function useSyncPathWithURL() {
13
13
  const history = useHistory();
14
- const { params } = useLocation();
15
- const { path = '/' } = params;
16
- const { location, goTo } = useNavigator();
17
- const currentPath = useRef( path );
18
- const currentNavigatorLocation = useRef( location.path );
14
+ const { params: urlParams } = useLocation();
15
+ const {
16
+ location: navigatorLocation,
17
+ params: navigatorParams,
18
+ goTo,
19
+ } = useNavigator();
20
+ const currentUrlParams = useRef( urlParams );
21
+ const currentPath = useRef();
22
+
19
23
  useEffect( () => {
20
- currentPath.current = path;
21
- if ( path !== currentNavigatorLocation.current ) {
22
- goTo( path );
24
+ // Don't trust the navigator path on initial render.
25
+ if ( currentPath.current === null ) {
26
+ return;
23
27
  }
24
- }, [ path ] );
25
- useEffect( () => {
26
- currentNavigatorLocation.current = location.path;
27
- if ( location.path !== currentPath.current ) {
28
- history.push( {
29
- ...params,
30
- path: location.path,
28
+ function updateUrlParams( newUrlParams ) {
29
+ if (
30
+ Object.entries( newUrlParams ).every( ( [ key, value ] ) => {
31
+ return currentUrlParams.current[ key ] === value;
32
+ } )
33
+ ) {
34
+ return;
35
+ }
36
+ const updatedParams = {
37
+ ...currentUrlParams.current,
38
+ ...newUrlParams,
39
+ };
40
+ currentUrlParams.current = updatedParams;
41
+ history.push( updatedParams );
42
+ }
43
+
44
+ if ( navigatorParams?.postType && navigatorParams?.postId ) {
45
+ updateUrlParams( {
46
+ postType: navigatorParams?.postType,
47
+ postId: navigatorParams?.postId,
48
+ path: undefined,
49
+ } );
50
+ } else if ( navigatorParams?.postType && ! navigatorParams?.postId ) {
51
+ updateUrlParams( {
52
+ postType: navigatorParams?.postType,
53
+ path: navigatorLocation.path,
54
+ postId: undefined,
55
+ } );
56
+ } else {
57
+ updateUrlParams( {
58
+ postType: undefined,
59
+ postId: undefined,
60
+ path: navigatorLocation.path,
31
61
  } );
32
62
  }
33
- }, [ location.path, history ] );
63
+ }, [ navigatorLocation?.path, navigatorParams, history ] );
34
64
 
35
- return path;
65
+ useEffect( () => {
66
+ currentUrlParams.current = urlParams;
67
+ let path = urlParams?.path ?? '/';
68
+
69
+ // Compute the navigator path based on the URL params.
70
+ if (
71
+ urlParams?.postType &&
72
+ urlParams?.postId &&
73
+ // This is just a special case to support old WP versions that perform redirects.
74
+ // This code should be removed when we minimum WP version becomes 6.2.
75
+ urlParams?.postId !== 'none'
76
+ ) {
77
+ switch ( urlParams.postType ) {
78
+ case 'wp_template':
79
+ case 'wp_template_part':
80
+ path = `/${ encodeURIComponent(
81
+ urlParams.postType
82
+ ) }/${ encodeURIComponent( urlParams.postId ) }`;
83
+ break;
84
+ default:
85
+ path = `/navigation/${ encodeURIComponent(
86
+ urlParams.postType
87
+ ) }/${ encodeURIComponent( urlParams.postId ) }`;
88
+ }
89
+ }
90
+
91
+ if ( currentPath.current !== path ) {
92
+ currentPath.current = path;
93
+ goTo( path );
94
+ }
95
+ goTo( path );
96
+ }, [ urlParams, goTo ] );
36
97
  }
@@ -7,5 +7,5 @@
7
7
  * @return {boolean} Is list page or not.
8
8
  */
9
9
  export default function getIsListPage( { path } ) {
10
- return path === '/templates/all' || path === '/template-parts/all';
10
+ return path === '/wp_template/all' || path === '/wp_template_part/all';
11
11
  }