Skip to content

Commit

Permalink
Zoom out: Reset zoom out level when device type is changed (#65652)
Browse files Browse the repository at this point in the history
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: draganescu <andraganescu@git.wordpress.org>
Co-authored-by: AhmarZaidi <ahmarzaidi@git.wordpress.org>
  • Loading branch information
4 people authored and gutenbergplugin committed Sep 25, 2024
1 parent 31de263 commit 5237aac
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/editor/src/components/preview-dropdown/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { ActionItem } from '@wordpress/interface';
import { store as editorStore } from '../../store';
import { store as blockEditorStore } from '@wordpress/block-editor';
import PostPreviewButton from '../post-preview-button';
import { unlock } from '../../lock-unlock';

export default function PreviewDropdown( { forceIsAutosaveable, disabled } ) {
const { deviceType, homeUrl, isTemplate, isViewable, showIconLabels } =
Expand All @@ -46,10 +47,12 @@ export default function PreviewDropdown( { forceIsAutosaveable, disabled } ) {
}, [] );
const { setDeviceType } = useDispatch( editorStore );
const { __unstableSetEditorMode } = useDispatch( blockEditorStore );
const { resetZoomLevel } = unlock( useDispatch( blockEditorStore ) );

const handleDevicePreviewChange = ( newDeviceType ) => {
setDeviceType( newDeviceType );
__unstableSetEditorMode( 'edit' );
resetZoomLevel();
};

const isMobile = useViewportMatch( 'medium', '<' );
Expand Down

0 comments on commit 5237aac

Please sign in to comment.