Skip to content

Commit

Permalink
Check available template first
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamaduka committed Jul 19, 2022
1 parent cf7dd1e commit 65ec4dc
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/edit-post/src/components/sidebar/post-template/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,16 @@ export default function PostTemplate() {

function PostTemplateToggle( { isOpen, onClick } ) {
const templateTitle = useSelect( ( select ) => {
return select( editPostStore ).getEditedPostTemplate()?.title;
const templateSlug =
select( editorStore ).getEditedPostAttribute( 'template' );

const settings = select( editorStore ).getEditorSettings();
if ( templateSlug && settings.availableTemplates[ templateSlug ] ) {
return settings.availableTemplates[ templateSlug ];
}

const template = select( editPostStore ).getEditedPostTemplate();
return template?.title ?? template?.slug;
}, [] );

return (
Expand Down

0 comments on commit 65ec4dc

Please sign in to comment.