Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Navigation Focus Mode: Remove leftover code #61897

Merged
merged 2 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 2 additions & 33 deletions packages/edit-site/src/components/block-editor/editor-canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import clsx from 'clsx';
/**
* WordPress dependencies
*/
import { store as blockEditorStore } from '@wordpress/block-editor';
import { useSelect, useDispatch } from '@wordpress/data';
import { ENTER, SPACE } from '@wordpress/keycodes';
import { useState, useEffect, useMemo } from '@wordpress/element';
Expand All @@ -21,32 +20,15 @@ import {
*/
import { unlock } from '../../lock-unlock';
import { store as editSiteStore } from '../../store';
import {
FOCUSABLE_ENTITIES,
NAVIGATION_POST_TYPE,
} from '../../utils/constants';

const { EditorCanvas: EditorCanvasRoot } = unlock( editorPrivateApis );

function EditorCanvas( { settings, children } ) {
const {
hasBlocks,
isFocusMode,
templateType,
canvasMode,
currentPostIsTrashed,
} = useSelect( ( select ) => {
const { getBlockCount } = select( blockEditorStore );
const { getEditedPostType, getCanvasMode } = unlock(
select( editSiteStore )
);
const _templateType = getEditedPostType();
const { canvasMode, currentPostIsTrashed } = useSelect( ( select ) => {
const { getCanvasMode } = unlock( select( editSiteStore ) );

return {
templateType: _templateType,
isFocusMode: FOCUSABLE_ENTITIES.includes( _templateType ),
canvasMode: getCanvasMode(),
hasBlocks: !! getBlockCount(),
currentPostIsTrashed:
select( editorStore ).getCurrentPostAttribute( 'status' ) ===
'trash',
Expand Down Expand Up @@ -92,15 +74,6 @@ function EditorCanvas( { settings, children } ) {
},
readonly: true,
};
const isTemplateTypeNavigation = templateType === NAVIGATION_POST_TYPE;
const isNavigationFocusMode = isTemplateTypeNavigation && isFocusMode;
// Hide the appender when:
// - In navigation focus mode (should only allow the root Nav block).
// - In view mode (i.e. not editing).
const showBlockAppender =
( isNavigationFocusMode && hasBlocks ) || canvasMode === 'view'
? false
: undefined;

const styles = useMemo(
() => [
Expand All @@ -123,10 +96,6 @@ function EditorCanvas( { settings, children } ) {

return (
<EditorCanvasRoot
className={ clsx( 'edit-site-editor-canvas__block-list', {
'is-navigation-block': isTemplateTypeNavigation,
} ) }
renderAppender={ showBlockAppender }
styles={ styles }
iframeProps={ {
className: clsx( 'edit-site-visual-editor__editor-canvas', {
Expand Down
6 changes: 0 additions & 6 deletions packages/edit-site/src/components/block-editor/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@
}
}

// Navigation focus mode requires padding around the root Navigation block
// for presentational purposes.
.edit-site-editor-canvas__block-list.is-navigation-block {
padding: $grid-unit-30;
}

.edit-site-visual-editor {
position: relative;
height: 100%;
Expand Down
4 changes: 0 additions & 4 deletions packages/editor/src/components/editor-canvas/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ function checkForPostContentAtRootLevel( blocks ) {
function EditorCanvas( {
// Ideally as we unify post and site editors, we won't need these props.
autoFocus,
className,
renderAppender,
styles,
disableIframe = false,
iframeProps,
Expand Down Expand Up @@ -454,7 +452,6 @@ function EditorCanvas( {
>
<BlockList
className={ clsx(
className,
'is-' + deviceType.toLowerCase() + '-preview',
renderingMode !== 'post-only' ||
isDesignPostType
Expand All @@ -469,7 +466,6 @@ function EditorCanvas( {
? localRef.current
: localRef.current?.parentNode
}
renderAppender={ renderAppender }
__unstableDisableDropZone={
// In template preview mode, disable drop zones at the root of the template.
renderingMode === 'template-locked'
Expand Down
Loading