diff --git a/packages/editor/src/components/text-editor/index.js b/packages/editor/src/components/text-editor/index.js index 6997c66826a12d..fa0688859b5a69 100644 --- a/packages/editor/src/components/text-editor/index.js +++ b/packages/editor/src/components/text-editor/index.js @@ -6,7 +6,6 @@ import { useDispatch, useSelect } from '@wordpress/data'; import { __ } from '@wordpress/i18n'; import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts'; import { useEffect, useRef } from '@wordpress/element'; -import { store as blockEditorStore } from '@wordpress/block-editor'; /** * Internal dependencies @@ -14,7 +13,6 @@ import { store as blockEditorStore } from '@wordpress/block-editor'; import { store as editorStore } from '../../store'; import PostTextEditor from '../post-text-editor'; import PostTitleRaw from '../post-title/post-title-raw'; -import { unlock } from '../../lock-unlock'; export default function TextEditor( { autoFocus = false } ) { const { switchEditorMode } = useDispatch( editorStore ); @@ -28,20 +26,13 @@ export default function TextEditor( { autoFocus = false } ) { }; }, [] ); - const { resetZoomLevel, __unstableSetEditorMode } = unlock( - useDispatch( blockEditorStore ) - ); - const titleRef = useRef(); useEffect( () => { - resetZoomLevel(); - __unstableSetEditorMode( 'edit' ); - if ( autoFocus ) { return; } titleRef?.current?.focus(); - }, [ autoFocus, resetZoomLevel, __unstableSetEditorMode ] ); + }, [ autoFocus ] ); return (
diff --git a/packages/editor/src/store/actions.js b/packages/editor/src/store/actions.js index 70be70c6293399..f28f5feeead179 100644 --- a/packages/editor/src/store/actions.js +++ b/packages/editor/src/store/actions.js @@ -883,9 +883,11 @@ export const switchEditorMode = ( { dispatch, registry } ) => { registry.dispatch( preferencesStore ).set( 'core', 'editorMode', mode ); - // Unselect blocks when we switch to a non visual mode. if ( mode !== 'visual' ) { + // Unselect blocks when we switch to a non visual mode. registry.dispatch( blockEditorStore ).clearSelectedBlock(); + // Exit zoom out state when switching to a non visual mode. + unlock( registry.dispatch( blockEditorStore ) ).resetZoomLevel(); } if ( mode === 'visual' ) {