diff --git a/packages/edit-site/src/components/page-switcher/index.js b/packages/edit-site/src/components/page-switcher/index.js index 5200ee9d95eee..ffef44bc45dc2 100644 --- a/packages/edit-site/src/components/page-switcher/index.js +++ b/packages/edit-site/src/components/page-switcher/index.js @@ -97,6 +97,7 @@ export default function PageSwitcher( { ].find( ( choice ) => choice.value === newPath ); onActivePageChange( { ...rest, path } ); }; + const onPostSelect = ( post ) => onActivePageChange( { type: 'post', @@ -104,6 +105,8 @@ export default function PageSwitcher( { path: getPathAndQueryString( post.url ), context: { postType: post.type, postId: post.id }, } ); + + const activePath = activePage?.path; return ( choice.value === activePage?.path - )?.label || activePage?.path, + ( choice ) => choice.value === activePath + )?.label || activePath, } } menuProps={ { className: 'edit-site-page-switcher__menu' } } > @@ -121,21 +124,21 @@ export default function PageSwitcher( {