From 3699b70ee93e66e59c547d3372633fe462f29a6c Mon Sep 17 00:00:00 2001 From: Andrew Serong <14988353+andrewserong@users.noreply.github.com> Date: Tue, 17 Jan 2023 09:38:29 +1100 Subject: [PATCH] Fix duplicate template parts logic overriding existing template part (#47128) --- .../src/components/add-new-template/new-template-part.js | 2 +- .../template-part-converter/convert-to-template-part.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/edit-site/src/components/add-new-template/new-template-part.js b/packages/edit-site/src/components/add-new-template/new-template-part.js index eb46c3e497bbc..35c50d7f43155 100644 --- a/packages/edit-site/src/components/add-new-template/new-template-part.js +++ b/packages/edit-site/src/components/add-new-template/new-template-part.js @@ -42,11 +42,11 @@ export default function NewTemplatePart( { } try { - const cleanSlug = getCleanTemplatePartSlug( title ); const uniqueTitle = getUniqueTemplatePartTitle( title, existingTemplateParts ); + const cleanSlug = getCleanTemplatePartSlug( uniqueTitle ); const templatePart = await saveEntityRecord( 'postType', diff --git a/packages/edit-site/src/components/template-part-converter/convert-to-template-part.js b/packages/edit-site/src/components/template-part-converter/convert-to-template-part.js index bfe9f2f46337c..33d9b6f70ace6 100644 --- a/packages/edit-site/src/components/template-part-converter/convert-to-template-part.js +++ b/packages/edit-site/src/components/template-part-converter/convert-to-template-part.js @@ -45,11 +45,11 @@ export default function ConvertToTemplatePart( { clientIds, blocks } ) { } const onConvert = async ( { title, area } ) => { - const cleanSlug = getCleanTemplatePartSlug( title ); const uniqueTitle = getUniqueTemplatePartTitle( title, existingTemplateParts ); + const cleanSlug = getCleanTemplatePartSlug( uniqueTitle ); const templatePart = await saveEntityRecord( 'postType',