diff --git a/packages/e2e-tests/specs/experiments/post-editor-template-mode.test.js b/packages/e2e-tests/specs/experiments/post-editor-template-mode.test.js index 1135441dfbad57..a1c01f4c7d9f65 100644 --- a/packages/e2e-tests/specs/experiments/post-editor-template-mode.test.js +++ b/packages/e2e-tests/specs/experiments/post-editor-template-mode.test.js @@ -53,7 +53,7 @@ const switchToTemplateMode = async () => { '.edit-post-template-top-area', ( el ) => el.innerText ); - expect( title ).toContain( 'About\n' ); + expect( title ).toContain( 'Just an FSE Post\n' ); }; const createNewTemplate = async ( templateName ) => { diff --git a/packages/edit-post/src/components/header/template-title/index.js b/packages/edit-post/src/components/header/template-title/index.js index 9aa21c0f27121d..3781f45242c557 100644 --- a/packages/edit-post/src/components/header/template-title/index.js +++ b/packages/edit-post/src/components/header/template-title/index.js @@ -1,29 +1,39 @@ /** * WordPress dependencies */ -import { __ } from '@wordpress/i18n'; -import { useSelect } from '@wordpress/data'; +import { __, sprintf } from '@wordpress/i18n'; +import { useSelect, useDispatch } from '@wordpress/data'; import { Dropdown, ToolbarItem, Button } from '@wordpress/components'; +import { chevronDown } from '@wordpress/icons'; /** * Internal dependencies */ import { store as editPostStore } from '../../../store'; +import { store as blockEditorStore } from '@wordpress/block-editor'; +import { store as editorStore } from '@wordpress/editor'; import DeleteTemplate from './delete-template'; import EditTemplateTitle from './edit-template-title'; function TemplateTitle() { - const { template, isEditing } = useSelect( ( select ) => { + const { template, isEditing, title } = useSelect( ( select ) => { const { isEditingTemplate, getEditedPostTemplate } = select( editPostStore ); + const { getEditedPostAttribute } = select( editorStore ); + const _isEditing = isEditingTemplate(); + return { template: _isEditing ? getEditedPostTemplate() : null, isEditing: _isEditing, + title: getEditedPostAttribute( 'title' ), }; }, [] ); + const { clearSelectedBlock } = useDispatch( blockEditorStore ); + const { setIsEditingTemplate } = useDispatch( editPostStore ); + if ( ! isEditing || ! template ) { return null; } @@ -45,13 +55,31 @@ function TemplateTitle() { contentClassName="edit-post-template-top-area__popover" renderToggle={ ( { onToggle } ) => ( <> -