diff --git a/packages/edit-site/src/components/page-patterns/use-patterns.js b/packages/edit-site/src/components/page-patterns/use-patterns.js index fde4eaadb5dc05..4b4e74a68bcaae 100644 --- a/packages/edit-site/src/components/page-patterns/use-patterns.js +++ b/packages/edit-site/src/components/page-patterns/use-patterns.js @@ -191,7 +191,7 @@ const patternBlockToPattern = ( patternBlock, categories ) => ( { categories: patternBlock.wp_pattern_category.map( ( patternCategoryId ) => categories && categories.get( patternCategoryId ) - ? categories.get( patternCategoryId ).slug + ? categories.get( patternCategoryId ).name : patternCategoryId ), } ), @@ -210,7 +210,7 @@ const patternBlockToPattern = ( patternBlock, categories ) => ( { const selectUserPatterns = createSelector( ( select, syncStatus, search = '' ) => { - const { getEntityRecords, getIsResolving, getUserPatternCategories } = + const { getEntityRecords, getIsResolving, getPatternCategories } = select( coreStore ); const query = { per_page: -1 }; @@ -219,11 +219,13 @@ const selectUserPatterns = createSelector( PATTERN_TYPES.user, query ); - const userPatternCategories = getUserPatternCategories(); + const patternCategories = getPatternCategories(); const categories = new Map(); - userPatternCategories.forEach( ( userCategory ) => - categories.set( userCategory.id, userCategory ) - ); + patternCategories.forEach( ( category ) => { + if ( category.id ) { + categories.set( category.id, category ); + } + } ); let patterns = records ? records.map( ( record ) => patternBlockToPattern( record, categories ) @@ -248,11 +250,10 @@ const selectUserPatterns = createSelector( // to be in the category. hasCategory: () => true, } ); - return { patterns, isResolving, - categories: userPatternCategories, + categories: patternCategories, }; }, ( select ) => [ diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-pattern/use-pattern-details.js b/packages/edit-site/src/components/sidebar-navigation-screen-pattern/use-pattern-details.js index b6a5a7948ea8a2..efa121768d0521 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-pattern/use-pattern-details.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-pattern/use-pattern-details.js @@ -106,7 +106,7 @@ export default function usePatternDetails( postType, postId ) { if ( record.wp_pattern_category?.length > 0 ) { const patternCategoriesMap = new Map(); patternCategories.forEach( ( userCategory ) => - patternCategories.set( userCategory.id, userCategory ) + patternCategoriesMap.set( userCategory.id, userCategory ) ); const categories = record.wp_pattern_category