Skip to content

Commit

Permalink
Post Template: Update template title selector
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamaduka committed Jul 19, 2022
1 parent ec8b279 commit cf7dd1e
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions packages/edit-post/src/components/sidebar/post-template/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { store as coreStore } from '@wordpress/core-data';
* Internal dependencies
*/
import PostTemplateForm from './form';
import { store as editPostStore } from '../../../store';

export default function PostTemplate() {
const anchorRef = useRef();
Expand Down Expand Up @@ -65,19 +66,7 @@ export default function PostTemplate() {

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

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

const template = select( coreStore )
.getEntityRecords( 'postType', 'wp_template', { per_page: -1 } )
?.find( ( { slug } ) => slug === templateSlug );

return template?.title.rendered;
return select( editPostStore ).getEditedPostTemplate()?.title;
}, [] );

return (
Expand Down

0 comments on commit cf7dd1e

Please sign in to comment.