From 5b30f82d632072e4497c053d005100eabbf9a002 Mon Sep 17 00:00:00 2001 From: Tetsuaki Hamano Date: Thu, 29 Jun 2023 22:08:57 +0900 Subject: [PATCH] removeTemplate: consider title type --- packages/edit-site/src/store/actions.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/edit-site/src/store/actions.js b/packages/edit-site/src/store/actions.js index 8da362ca01f17d..ac07ac5beaa2af 100644 --- a/packages/edit-site/src/store/actions.js +++ b/packages/edit-site/src/store/actions.js @@ -141,11 +141,18 @@ export const removeTemplate = throw lastError; } + // Depending on how the entity was retrieved it's title might be + // an object or simple string. + const templateTitle = + typeof template.title === 'string' + ? template.title + : template.title?.rendered; + registry.dispatch( noticesStore ).createSuccessNotice( sprintf( /* translators: The template/part's name. */ __( '"%s" deleted.' ), - decodeEntities( template.title.rendered ) + decodeEntities( templateTitle ) ), { type: 'snackbar', id: 'site-editor-template-deleted-success' } );