From 3ca64924075b6eab980afaad765ef97a86f10158 Mon Sep 17 00:00:00 2001 From: ramon Date: Thu, 21 Sep 2023 14:38:40 +1000 Subject: [PATCH] Set decoded title var Ensure correct back path when deleting templates --- .../sidebar-navigation-screen-template/index.js | 7 ++++++- .../src/components/template-actions/index.js | 13 ++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) 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 fd60d0a509ace2..e63b33ef169915 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 @@ -98,6 +98,11 @@ export default function SidebarNavigationScreenTemplate() { postId ); + // The absence of a post type in the query params for templates + // indicates the user has arrived at the template via the "manage all" + // page and the back button should return them to that list page. + const backPath = + postType !== 'wp_template' ? `/${ postType }/all` : `/${ postType }`; return ( { - navigator.goTo( `/${ postType }/all` ); + navigator.goTo( backPath ); } } /> { try { @@ -71,9 +74,7 @@ export default function TemplateActions( { sprintf( // translators: %s: The pattern's title e.g. 'Call to action'. __( '"%s" deleted.' ), - decodeEntities( - pattern?.title?.rendered || pattern?.title?.raw - ) + decodedTitle ), { type: 'snackbar', id: 'edit-site-patterns-success' } ); @@ -106,7 +107,7 @@ export default function TemplateActions( { sprintf( /* translators: The template/part's name. */ __( '"%s" reverted.' ), - decodeEntities( item.title.rendered ) + decodedTitle ), { type: 'snackbar', @@ -159,9 +160,7 @@ export default function TemplateActions( { onRemove?.(); onClose(); } } - title={ decodeEntities( - record.title.rendered || record.title.raw - ) } + title={ decodedTitle } /> ) }