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

Fix zoom out not persisting while switching between editor and code editor #65932

Merged
merged 3 commits into from
Oct 18, 2024
Merged
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
11 changes: 10 additions & 1 deletion packages/editor/src/components/text-editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ 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
*/
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 );
Expand All @@ -26,13 +28,20 @@ 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 ] );
}, [ autoFocus, resetZoomLevel, __unstableSetEditorMode ] );

return (
<div className="editor-text-editor">
Expand Down
Loading