From 348889e717343d1e5c988ba586955d1a26252d24 Mon Sep 17 00:00:00 2001 From: Robert Anderson Date: Thu, 21 Mar 2024 14:46:39 +1100 Subject: [PATCH] Rendering mode should be 'all' in post editor when editing a template or template part --- packages/edit-post/src/editor.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/edit-post/src/editor.js b/packages/edit-post/src/editor.js index fd44d3dae4ca4a..84f31317592668 100644 --- a/packages/edit-post/src/editor.js +++ b/packages/edit-post/src/editor.js @@ -38,7 +38,7 @@ function Editor( { onNavigateToPreviousEntityRecord, } = useNavigateToEntityRecord( initialPostId, initialPostType ); - const { post, template } = useSelect( + const { post, template, defaultRenderingMode } = useSelect( ( select ) => { const { getEditedPostTemplate } = select( editPostStore ); const { getEntityRecord, getPostType, canUser } = @@ -65,6 +65,11 @@ function Editor( { ? getEditedPostTemplate() : null, post: postObject, + defaultRenderingMode: + currentPost.postType === 'wp_template' || + currentPost.postType === 'wp_template_part' + ? 'all' + : 'post-only', }; }, [ currentPost.postType, currentPost.postId ] @@ -75,9 +80,14 @@ function Editor( { ...settings, onNavigateToEntityRecord, onNavigateToPreviousEntityRecord, - defaultRenderingMode: 'post-only', + defaultRenderingMode, } ), - [ settings, onNavigateToEntityRecord, onNavigateToPreviousEntityRecord ] + [ + settings, + onNavigateToEntityRecord, + onNavigateToPreviousEntityRecord, + defaultRenderingMode, + ] ); if ( ! post ) {