From 3303a45bc8aff72ba03f06999913e9e811678e47 Mon Sep 17 00:00:00 2001 From: Glen Davies Date: Mon, 8 May 2023 18:09:21 +1200 Subject: [PATCH] Sort templates by the rendered title instead of the slug (#50353) --- packages/edit-site/src/components/list/table.js | 4 +++- .../components/sidebar-navigation-screen-templates/index.js | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/edit-site/src/components/list/table.js b/packages/edit-site/src/components/list/table.js index 358807dc2e076b..59ff5a9187ab09 100644 --- a/packages/edit-site/src/components/list/table.js +++ b/packages/edit-site/src/components/list/table.js @@ -61,7 +61,9 @@ export default function Table( { templateType } ) { } const sortedTemplates = [ ...templates ]; - sortedTemplates.sort( ( a, b ) => a.slug.localeCompare( b.slug ) ); + sortedTemplates.sort( ( a, b ) => + a.title.rendered.localeCompare( b.title.rendered ) + ); return ( // These explicit aria roles are needed for Safari. diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-templates/index.js b/packages/edit-site/src/components/sidebar-navigation-screen-templates/index.js index 5a6dc4a37fa9a9..8c9c5638884737 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-templates/index.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-templates/index.js @@ -74,7 +74,9 @@ export default function SidebarNavigationScreenTemplates() { } ); const sortedTemplates = templates ? [ ...templates ] : []; - sortedTemplates.sort( ( a, b ) => a.slug.localeCompare( b.slug ) ); + sortedTemplates.sort( ( a, b ) => + a.title.rendered.localeCompare( b.title.rendered ) + ); const browseAllLink = useLink( { path: '/' + postType + '/all',