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

Zoomed-Out Mode: Don't show blocks in zoomed out view #59245

Merged
merged 6 commits into from
Feb 24, 2024
Merged
Changes from 1 commit
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
Next Next commit
Zoomed Out: Don't show blocks when inserting in zoomed out mode
  • Loading branch information
scruffian committed Feb 24, 2024
commit 48766b0d749e760bf4136cd70ba9bc7c14acb386
10 changes: 7 additions & 3 deletions packages/block-editor/src/components/inserter/menu.js
Original file line number Diff line number Diff line change
@@ -66,10 +66,13 @@ function InserterMenu(
insertionIndex: __experimentalInsertionIndex,
shouldFocusBlock,
} );
const { showPatterns } = useSelect(
const { showBlocks, showPatterns } = useSelect(
( select ) => {
const { hasAllowedPatterns } = unlock( select( blockEditorStore ) );
const { hasAllowedPatterns, __unstableGetEditorMode } = unlock(
select( blockEditorStore )
);
return {
showBlocks: __unstableGetEditorMode() !== 'zoom-out',
showPatterns: hasAllowedPatterns( destinationRootClientId ),
};
},
@@ -248,13 +251,14 @@ function InserterMenu(
__experimentalInsertionIndex={
__experimentalInsertionIndex
}
showBlockDirectory
showBlockDirectory={ showBlocks }
shouldFocusBlock={ shouldFocusBlock }
/>
</div>
) }
{ showAsTabs && (
<InserterTabs
showBlocks={ showBlocks }
showPatterns={ showPatterns }
showMedia={ showMedia }
onSelect={ handleSetSelectedTab }
3 changes: 2 additions & 1 deletion packages/block-editor/src/components/inserter/tabs.js
Original file line number Diff line number Diff line change
@@ -29,13 +29,14 @@ const mediaTab = {
};

function InserterTabs( {
showBlocks = true,
showPatterns = false,
showMedia = false,
onSelect,
tabsContents,
} ) {
const tabs = [
blocksTab,
showBlocks && blocksTab,
showPatterns && patternsTab,
showMedia && mediaTab,
].filter( Boolean );