From bec0e41bbbebf2b565e0a80f421611955a0e02b7 Mon Sep 17 00:00:00 2001 From: Jorge Costa Date: Mon, 23 Dec 2024 18:16:23 +0000 Subject: [PATCH] enhacements --- packages/core-data/src/private-selectors.ts | 3 +-- packages/editor/src/components/provider/index.js | 11 +++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/core-data/src/private-selectors.ts b/packages/core-data/src/private-selectors.ts index 9249da5c6a05a1..5b650b60618b85 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 3b061424655b6c..ada9c3964ca8aa 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 ); + }, [ setRenderingMode, defaultMode ] ); useHideBlocksFromInserter( post.type, mode );