diff --git a/packages/edit-post/src/components/header/template-title/delete-template.js b/packages/edit-post/src/components/header/template-title/delete-template.js index 3a6d25f2a1a8fd..6a6e6f58f0df18 100644 --- a/packages/edit-post/src/components/header/template-title/delete-template.js +++ b/packages/edit-post/src/components/header/template-title/delete-template.js @@ -59,7 +59,6 @@ export default function DeleteTemplate() { ) ); updateEditorSettings( { - ...settings, availableTemplates: newAvailableTemplates, } ); deleteEntityRecord( 'postType', 'wp_template', template.id, { diff --git a/packages/edit-post/src/components/header/template-title/edit-template-title.js b/packages/edit-post/src/components/header/template-title/edit-template-title.js index 56970f25aafe67..447ea5e4e02d72 100644 --- a/packages/edit-post/src/components/header/template-title/edit-template-title.js +++ b/packages/edit-post/src/components/header/template-title/edit-template-title.js @@ -58,16 +58,13 @@ export default function EditTemplateTitle() { const settings = getEditorSettings(); const newAvailableTemplates = Object.fromEntries( Object.entries( settings.availableTemplates ?? {} ).map( - ( [ id, existingTitle ] ) => { - if ( id !== template.slug ) { - return existingTitle; - } - return newTitle; - } + ( [ id, existingTitle ] ) => [ + id, + id !== template.slug ? existingTitle : newTitle, + ] ) ); updateEditorSettings( { - ...settings, availableTemplates: newAvailableTemplates, } ); editEntityRecord( 'postType', 'wp_template', template.id, {