Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Post Template: Update template title selector #42091

Merged
merged 3 commits into from
Aug 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 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 @@ -68,16 +69,14 @@ function PostTemplateToggle( { isOpen, onClick } ) {
const templateSlug =
select( editorStore ).getEditedPostAttribute( 'template' );

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

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

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

return (
Expand Down