diff --git a/packages/fields/src/fields/template/template-edit.tsx b/packages/fields/src/fields/template/template-edit.tsx index aee40d792afef..e323da91bd4bd 100644 --- a/packages/fields/src/fields/template/template-edit.tsx +++ b/packages/fields/src/fields/template/template-edit.tsx @@ -192,11 +192,29 @@ export const TemplateEdit = ( { : '' } ) } - renderContent={ () => ( + renderContent={ ( { onToggle } ) => ( - setShowModal( true ) }> + { + setShowModal( true ); + onToggle(); + } } + > { __( 'Swap template' ) } + { + // The default template in a post is indicated by an empty string + value !== '' && ( + { + onChangeControl( '' ); + onToggle(); + } } + > + { __( 'Use default template' ) } + + ) + } ) } /> @@ -212,8 +230,11 @@ export const TemplateEdit = ( { label={ __( 'Templates' ) } blockPatterns={ templatesAsPatterns } shownPatterns={ shownTemplates } - onClickPattern={ ( template: WpTemplate ) => { - onChangeControl( template.id ); + onClickPattern={ ( + template: ( typeof templatesAsPatterns )[ 0 ] + ) => { + onChangeControl( template.name ); + setShowModal( false ); } } />