diff --git a/packages/edit-site/src/components/block-editor/editor-canvas.js b/packages/edit-site/src/components/block-editor/editor-canvas.js index 15d638aa329e1..137018da1eb82 100644 --- a/packages/edit-site/src/components/block-editor/editor-canvas.js +++ b/packages/edit-site/src/components/block-editor/editor-canvas.js @@ -26,6 +26,7 @@ import { FOCUSABLE_ENTITIES, NAVIGATION_POST_TYPE, } from '../../utils/constants'; +import useIsNavigationOverlay from './use-is-navigation-overlay'; const { ExperimentalBlockCanvas: BlockCanvas } = unlock( blockEditorPrivateApis @@ -68,6 +69,7 @@ function EditorCanvas( { const { setCanvasMode } = unlock( useDispatch( editSiteStore ) ); const deviceStyles = useResizeCanvas( deviceType ); const [ isFocused, setIsFocused ] = useState( false ); + const isNavigationOverlayTemplate = useIsNavigationOverlay(); useEffect( () => { if ( canvasMode === 'edit' ) { @@ -95,9 +97,12 @@ function EditorCanvas( { const isNavigationFocusMode = isTemplateTypeNavigation && isFocusMode; // Hide the appender when: // - In navigation focus mode (should only allow the root Nav block). + // - editing the navigation overlay template. // - In view mode (i.e. not editing). const showBlockAppender = - ( isNavigationFocusMode && hasBlocks ) || canvasMode === 'view' + ( isNavigationFocusMode && hasBlocks ) || + isNavigationOverlayTemplate || + canvasMode === 'view' ? false : undefined; diff --git a/packages/edit-site/src/components/block-editor/site-editor-canvas.js b/packages/edit-site/src/components/block-editor/site-editor-canvas.js index 953f45ab4c8e4..1fd98d5b3e2ba 100644 --- a/packages/edit-site/src/components/block-editor/site-editor-canvas.js +++ b/packages/edit-site/src/components/block-editor/site-editor-canvas.js @@ -9,7 +9,6 @@ import { useSelect, useDispatch } from '@wordpress/data'; import { useRef } from '@wordpress/element'; import { BlockTools, store as blockEditorStore } from '@wordpress/block-editor'; import { useViewportMatch, useResizeObserver } from '@wordpress/compose'; -import { useEntityProp } from '@wordpress/core-data'; /** * Internal dependencies @@ -26,11 +25,7 @@ import { } from '../../utils/constants'; import { unlock } from '../../lock-unlock'; import PageContentFocusNotifications from '../page-content-focus-notifications'; - -function useIsNavigationOverlay() { - const [ area ] = useEntityProp( 'postType', 'wp_template_part', 'area' ); - return area === 'navigation-overlay'; -} +import useIsNavigationOverlay from './use-is-navigation-overlay'; export default function SiteEditorCanvas() { const { clearSelectedBlock } = useDispatch( blockEditorStore ); diff --git a/packages/edit-site/src/components/block-editor/use-is-navigation-overlay.js b/packages/edit-site/src/components/block-editor/use-is-navigation-overlay.js new file mode 100644 index 0000000000000..53bd7b19feec7 --- /dev/null +++ b/packages/edit-site/src/components/block-editor/use-is-navigation-overlay.js @@ -0,0 +1,9 @@ +/** + * WordPress dependencies + */ +import { useEntityProp } from '@wordpress/core-data'; + +export default function useIsNavigationOverlay() { + const [ area ] = useEntityProp( 'postType', 'wp_template_part', 'area' ); + return area === 'navigation-overlay'; +}