diff --git a/packages/block-editor/src/components/iframe/index.js b/packages/block-editor/src/components/iframe/index.js
index 669e2fe25a9fbb..3a0823f1c3cd47 100644
--- a/packages/block-editor/src/components/iframe/index.js
+++ b/packages/block-editor/src/components/iframe/index.js
@@ -242,10 +242,8 @@ function Iframe( {
const isZoomedOut = scale !== 1;
useEffect( () => {
- if ( ! isZoomedOut ) {
- prevContainerWidth.current = containerWidth;
- }
- }, [ containerWidth, isZoomedOut ] );
+ prevContainerWidth.current = containerWidth;
+ }, [ containerWidth ] );
const disabledRef = useDisabled( { isDisabled: ! readonly } );
const bodyRef = useMergeRefs( [
diff --git a/packages/block-editor/src/components/inserter/menu.js b/packages/block-editor/src/components/inserter/menu.js
index 17a98570843014..d3f2fd1831d426 100644
--- a/packages/block-editor/src/components/inserter/menu.js
+++ b/packages/block-editor/src/components/inserter/menu.js
@@ -10,6 +10,7 @@ import {
forwardRef,
useState,
useCallback,
+ useEffect,
useMemo,
useRef,
useLayoutEffect,
@@ -17,7 +18,7 @@ import {
import { VisuallyHidden, SearchControl, Popover } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { useDebouncedInput } from '@wordpress/compose';
-import { useSelect } from '@wordpress/data';
+import { useSelect, useDispatch } from '@wordpress/data';
/**
* Internal dependencies
@@ -32,7 +33,6 @@ import InserterSearchResults from './search-results';
import useInsertionPoint from './hooks/use-insertion-point';
import { store as blockEditorStore } from '../../store';
import TabbedSidebar from '../tabbed-sidebar';
-import { useZoomOut } from '../../hooks/use-zoom-out';
const NOOP = () => {};
function InserterMenu(
@@ -149,7 +149,18 @@ function InserterMenu(
const showZoomOut =
showPatternPanel && !! window.__experimentalEnableZoomedOutPatternsTab;
- useZoomOut( showZoomOut );
+ const { __unstableSetEditorMode } = useDispatch( blockEditorStore );
+ useEffect( () => {
+ if ( showZoomOut ) {
+ __unstableSetEditorMode( 'zoom-out' );
+ }
+
+ return () => {
+ if ( showZoomOut ) {
+ __unstableSetEditorMode( 'edit' ); // TODO: set back to whatever it was previously
+ }
+ };
+ }, [ showZoomOut ] );
const inserterSearch = useMemo( () => {
if ( selectedTab === 'media' ) {
diff --git a/packages/editor/src/components/header/index.js b/packages/editor/src/components/header/index.js
index 2a604229596005..b8eda30c721860 100644
--- a/packages/editor/src/components/header/index.js
+++ b/packages/editor/src/components/header/index.js
@@ -57,7 +57,6 @@ function Header( {
showIconLabels,
hasFixedToolbar,
isNestedEntity,
- isZoomedOutView,
} = useSelect( ( select ) => {
const { get: getPreference } = select( preferencesStore );
const {
@@ -136,7 +135,7 @@ function Header( {
) }
{
+ if ( __unstableGetEditorMode() === 'zoom-out' ) {
+ return __( '50%' );
+ }
+ return __( '100%' );
+ };
+
+ const getIcon = () => {
+ if ( isZoomOutExperiment && deviceType === 'Desktop' ) {
+ return zoomIcon;
+ }
+ return deviceIcons[ deviceType.toLowerCase() ];
+ };
+
+ function handleDevicePreviewClick( targetDeviceType, editorMode ) {
+ if ( isZoomOutExperiment ) {
+ __unstableSetEditorMode( editorMode );
+ }
+ setDeviceType( targetDeviceType );
+ }
+
return (
@@ -76,19 +103,53 @@ export default function PreviewDropdown( { forceIsAutosaveable, disabled } ) {
<>
+ { isZoomOutExperiment && (
+
+ ) }