Skip to content

Commit

Permalink
Re-hide appender following changes in rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
getdave committed Dec 6, 2023
1 parent fe1e057 commit f439bc4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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' ) {
Expand Down Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 );
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
}

0 comments on commit f439bc4

Please sign in to comment.