Skip to content

Commit

Permalink
Post Template: fix broken title editing (#49984)
Browse files Browse the repository at this point in the history
* Post template title edit: update only the avaiableTemplates setting

* Post template title edit: fix broken rename code
  • Loading branch information
jsnajdr authored and fullofcaffeine committed Apr 21, 2023
1 parent 6b9b84d commit e92348d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ export default function DeleteTemplate() {
)
);
updateEditorSettings( {
...settings,
availableTemplates: newAvailableTemplates,
} );
deleteEntityRecord( 'postType', 'wp_template', template.id, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down

0 comments on commit e92348d

Please sign in to comment.