diff --git a/packages/core-data/src/private-selectors.ts b/packages/core-data/src/private-selectors.ts index 9249da5c6a05a..5b650b60618b8 100644 --- a/packages/core-data/src/private-selectors.ts +++ b/packages/core-data/src/private-selectors.ts @@ -171,8 +171,7 @@ export const getHomePage = createRegistrySelector( ( select ) => canUser( state, 'read', { kind: 'root', name: 'site', - } ), - getEntityRecord( state, 'root', 'site' ), + } ) && getEntityRecord( state, 'root', 'site' ), getDefaultTemplateId( state, { slug: 'front-page', } ), diff --git a/packages/editor/src/components/provider/index.js b/packages/editor/src/components/provider/index.js index 3b061424655b6..50af9583b72a5 100644 --- a/packages/editor/src/components/provider/index.js +++ b/packages/editor/src/components/provider/index.js @@ -196,7 +196,9 @@ export const ExperimentalEditorProvider = withRegistryProvider( isReady: __unstableIsEditorReady(), mode: getRenderingMode(), defaultMode: - postTypeObject?.default_rendering_mode ?? 'post-only', + hasTemplate && postTypeObject?.default_rendering_mode + ? postTypeObject?.default_rendering_mode + : 'post-only', selection: getEditorSelection(), postTypeEntities: post.type === 'wp_template' @@ -204,7 +206,7 @@ export const ExperimentalEditorProvider = withRegistryProvider( : null, }; }, - [ post.type ] + [ post.type, hasTemplate ] ); const shouldRenderTemplate = !! template && mode !== 'post-only'; @@ -309,6 +311,7 @@ export const ExperimentalEditorProvider = withRegistryProvider( recovery, setupEditor, updatePostLock, + hasTemplate, ] ); // Synchronizes the active post with the state @@ -328,8 +331,8 @@ export const ExperimentalEditorProvider = withRegistryProvider( // Sets the right rendering mode when loading the editor. useEffect( () => { - setRenderingMode( hasTemplate ? defaultMode : 'post-only' ); - }, [ hasTemplate, defaultMode, setRenderingMode ] ); + setRenderingMode( defaultMode ); + }, [ defaultMode, setRenderingMode ] ); useHideBlocksFromInserter( post.type, mode );