diff --git a/packages/block-editor/src/components/inserter/menu.js b/packages/block-editor/src/components/inserter/menu.js index 17a98570843014..cf8eae6a88ff04 100644 --- a/packages/block-editor/src/components/inserter/menu.js +++ b/packages/block-editor/src/components/inserter/menu.js @@ -17,7 +17,7 @@ import { import { VisuallyHidden, SearchControl, Popover } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; import { useDebouncedInput } from '@wordpress/compose'; -import { useSelect } from '@wordpress/data'; +import { useDispatch, useSelect } from '@wordpress/data'; /** * Internal dependencies @@ -32,7 +32,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( @@ -58,6 +57,7 @@ function InserterMenu( select( blockEditorStore ).__unstableGetEditorMode() === 'zoom-out', [] ); + const { __unstableSetEditorMode } = useDispatch( blockEditorStore ); const [ filterValue, setFilterValue, delayedFilterValue ] = useDebouncedInput( __experimentalFilterValue ); const [ hoveredItem, setHoveredItem ] = useState( null ); @@ -135,6 +135,7 @@ function InserterMenu( setSelectedPatternCategory( patternCategory ); setPatternFilter( filter ); onPatternCategorySelection?.(); + __unstableSetEditorMode( 'zoom-out' ); }, [ setSelectedPatternCategory, onPatternCategorySelection ] ); @@ -146,11 +147,6 @@ function InserterMenu( const showMediaPanel = selectedTab === 'media' && !! selectedMediaCategory; - const showZoomOut = - showPatternPanel && !! window.__experimentalEnableZoomedOutPatternsTab; - - useZoomOut( showZoomOut ); - const inserterSearch = useMemo( () => { if ( selectedTab === 'media' ) { return null; 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( { ) } + { !! window.__experimentalEnableZoomedOutPatternsTab && ( + + { __unstableGetEditorMode() !== 'zoom-out' && ( + + __unstableSetEditorMode( 'zoom-out' ) + } + > + { __( 'Zoom Out' ) } + + ) } + { __unstableGetEditorMode() === 'zoom-out' && ( + + __unstableSetEditorMode( 'edit' ) + } + > + { __( 'Zoom In' ) } + + ) } + + ) } { isTemplate && (