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

Remove patterns from the Quick Inserter to prevent misuse in block-specific contexts #67738

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from
Open
Changes from 2 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
25 changes: 2 additions & 23 deletions packages/block-editor/src/components/inserter/quick-inserter.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,11 @@ import { useSelect } from '@wordpress/data';
*/
import InserterSearchResults from './search-results';
import useInsertionPoint from './hooks/use-insertion-point';
import usePatternsState from './hooks/use-patterns-state';
import useBlockTypesState from './hooks/use-block-types-state';
import { store as blockEditorStore } from '../../store';

const SEARCH_THRESHOLD = 6;
const SHOWN_BLOCK_TYPES = 6;
const SHOWN_BLOCK_PATTERNS = 2;
const SHOWN_BLOCK_PATTERNS_WITH_PRIORITIZATION = 4;

export default function QuickInserter( {
onSelect,
Expand All @@ -47,12 +44,6 @@ export default function QuickInserter( {
onInsertBlocks,
true
);
const [ patterns ] = usePatternsState(
onInsertBlocks,
destinationRootClientId,
undefined,
true
);

const { setInserterIsOpened, insertionIndex } = useSelect(
( select ) => {
Expand All @@ -70,12 +61,7 @@ export default function QuickInserter( {
[ clientId ]
);

const showPatterns =
patterns.length && ( !! filterValue || prioritizePatterns );
const showSearch =
hasSearch &&
( ( showPatterns && patterns.length > SEARCH_THRESHOLD ) ||
blockTypes.length > SEARCH_THRESHOLD );
const showSearch = hasSearch && blockTypes.length > SEARCH_THRESHOLD;

useEffect( () => {
if ( setInserterIsOpened ) {
Expand All @@ -94,13 +80,6 @@ export default function QuickInserter( {
} );
};

let maxBlockPatterns = 0;
if ( showPatterns ) {
maxBlockPatterns = prioritizePatterns
? SHOWN_BLOCK_PATTERNS_WITH_PRIORITIZATION
: SHOWN_BLOCK_PATTERNS;
}

return (
<div
className={ clsx( 'block-editor-inserter__quick-inserter', {
Expand Down Expand Up @@ -128,7 +107,7 @@ export default function QuickInserter( {
rootClientId={ rootClientId }
clientId={ clientId }
isAppender={ isAppender }
maxBlockPatterns={ maxBlockPatterns }
maxBlockPatterns={ 0 }
maxBlockTypes={ SHOWN_BLOCK_TYPES }
isDraggable={ false }
prioritizePatterns={ prioritizePatterns }
Expand Down
Loading