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

Avoid zooming out when browsing styles if the preview mode is active #67190

Merged
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
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
/**
* WordPress dependencies
*/
import {
privateApis as blockEditorPrivateApis,
store as blockEditorStore,
} from '@wordpress/block-editor';
import { Card, CardBody } from '@wordpress/components';
import { useSelect, useDispatch } from '@wordpress/data';
import { __ } from '@wordpress/i18n';
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
import { useDispatch } from '@wordpress/data';
import { store as editorStore } from '@wordpress/editor';
import { useEffect } from '@wordpress/element';

Expand All @@ -19,10 +22,13 @@ const { useZoomOut } = unlock( blockEditorPrivateApis );

function ScreenStyleVariations() {
// Style Variations should only be previewed in with
// - a "zoomed out" editor
// - a "zoomed out" editor (but not when in preview mode)
// - "Desktop" device preview
const isPreviewMode = useSelect( ( select ) => {
return select( blockEditorStore ).getSettings().isPreviewMode;
}, [] );
const { setDeviceType } = useDispatch( editorStore );
useZoomOut();
useZoomOut( ! isPreviewMode );
useEffect( () => {
setDeviceType( 'desktop' );
}, [ setDeviceType ] );
Expand Down
Loading