Skip to content

Commit

Permalink
Avoid zooming out when browsing styles if the preview mode is active (#…
Browse files Browse the repository at this point in the history
…67190)

Co-authored-by: talldan <[email protected]>
Co-authored-by: tellthemachines <[email protected]>
Co-authored-by: ramonjd <[email protected]>
Co-authored-by: draganescu <[email protected]>
Co-authored-by: yogeshbhutkar <[email protected]>
Co-authored-by: jameskoster <[email protected]>
  • Loading branch information
7 people authored Nov 22, 2024
1 parent 98a7d5d commit a7c373f
Showing 1 changed file with 10 additions and 4 deletions.
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

1 comment on commit a7c373f

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in a7c373f.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/11964949350
📝 Reported issues:

Please sign in to comment.