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

Zoom Out: Move the hook to the inserter component #63315

Merged
merged 1 commit into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
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
Expand Up @@ -2,9 +2,8 @@
* Internal dependencies
*/
import { PatternCategoryPreviews } from './pattern-category-previews';
import { useZoomOut } from '../../../hooks/use-zoom-out';

function PatternCategoryPreviewPanelInner( {
export function PatternCategoryPreviewPanel( {
rootClientId,
onInsert,
onHover,
Expand All @@ -24,17 +23,3 @@ function PatternCategoryPreviewPanelInner( {
/>
);
}

function PatternCategoryPreviewPanelWithZoomOut( props ) {
useZoomOut();
return <PatternCategoryPreviewPanelInner { ...props } />;
}

export function PatternCategoryPreviewPanel( props ) {
// When the pattern panel is showing, we want to use zoom out mode
if ( window.__experimentalEnableZoomedOutPatternsTab ) {
return <PatternCategoryPreviewPanelWithZoomOut { ...props } />;
}

return <PatternCategoryPreviewPanelInner { ...props } />;
}
6 changes: 6 additions & 0 deletions packages/block-editor/src/components/inserter/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ 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(
Expand Down Expand Up @@ -145,6 +146,11 @@ function InserterMenu(

const showMediaPanel = selectedTab === 'media' && !! selectedMediaCategory;

const showZoomOut =
showPatternPanel && window.__experimentalEnableZoomedOutPatternsTab;

useZoomOut( showZoomOut );

const inserterSearch = useMemo( () => {
if ( selectedTab === 'media' ) {
return null;
Expand Down
Loading