Skip to content

Commit

Permalink
Site Editor: Fix description in GetTemplateInfo (#41394)
Browse files Browse the repository at this point in the history
* Site Editor: Fix description in GetTemplateInfo
* Update unit tests
  • Loading branch information
Mamaduka authored and youknowriad committed Jun 3, 2022
1 parent 230532c commit 85d0c28
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions packages/editor/src/store/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -1606,14 +1606,16 @@ export function __experimentalGetTemplateInfo( state, template ) {
return {};
}

const { excerpt, slug, title, area } = template;
const { description, slug, title, area } = template;
const {
title: defaultTitle,
description: defaultDescription,
} = __experimentalGetDefaultTemplateType( state, slug );

const templateTitle = isString( title ) ? title : title?.rendered;
const templateDescription = isString( excerpt ) ? excerpt : excerpt?.raw;
const templateDescription = isString( description )
? description
: description?.raw;
const templateIcon =
__experimentalGetDefaultTemplatePartAreas( state ).find(
( item ) => area === item.area
Expand Down
6 changes: 3 additions & 3 deletions packages/editor/src/store/test/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -2968,7 +2968,7 @@ describe( 'selectors', () => {
expect(
__experimentalGetTemplateInfo( state, {
slug: 'index',
excerpt: { raw: 'test description' },
description: { raw: 'test description' },
} ).description
).toEqual( 'test description' );
} );
Expand Down Expand Up @@ -2996,7 +2996,7 @@ describe( 'selectors', () => {
expect(
__experimentalGetTemplateInfo( state, {
slug: 'index',
excerpt: { raw: 'test description' },
description: { raw: 'test description' },
} )
).toEqual( {
title: 'Default (Index)',
Expand All @@ -3008,7 +3008,7 @@ describe( 'selectors', () => {
__experimentalGetTemplateInfo( state, {
slug: 'index',
title: { rendered: 'test title' },
excerpt: { raw: 'test description' },
description: { raw: 'test description' },
} )
).toEqual( {
title: 'test title',
Expand Down

0 comments on commit 85d0c28

Please sign in to comment.