Skip to content

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgefilipecosta committed Feb 14, 2022
1 parent ff1f5d3 commit 460be3c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ export default function QuickInserter( {
return {
setInserterIsOpened: settings.__experimentalSetIsInserterOpened,
prioritizePatterns:
settings.__experimentalPrioritizePatternsOnQuickInserterRoot &&
settings.__experimentalPreferPatternsOnRoot &&
! rootClientId &&
index > 0 &&
index < blockCount,
( index < blockCount || blockCount === 0 ),
insertionIndex: index === -1 ? blockCount : index,
};
},
Expand Down Expand Up @@ -128,7 +128,7 @@ export default function QuickInserter( {
maxBlockPatterns={ maxBlockPatterns }
maxBlockTypes={ SHOWN_BLOCK_TYPES }
isDraggable={ false }
__experimentalPrioritizePatterns={ prioritizePatterns }
prioritizePatterns={ prioritizePatterns }
/>
</div>

Expand Down
17 changes: 10 additions & 7 deletions packages/block-editor/src/components/inserter/search-results.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function InserterSearchResults( {
showBlockDirectory = false,
isDraggable = true,
shouldFocusBlock = true,
__experimentalPrioritizePatterns,
prioritizePatterns,
} ) {
const debouncedSpeak = useDebounce( speak, 500 );

Expand All @@ -72,21 +72,24 @@ function InserterSearchResults( {
);

const filteredBlockPatterns = useMemo( () => {
if ( maxBlockPatterns === 0 ) {
return [];
}
const results = searchItems( patterns, filterValue );
return maxBlockPatterns !== undefined
? results.slice( 0, maxBlockPatterns )
: results;
}, [ filterValue, patterns, maxBlockPatterns ] );

let maxBlockTypesToShow = maxBlockTypes;
if (
__experimentalPrioritizePatterns &&
filteredBlockPatterns.length > 2
) {
if ( prioritizePatterns && filteredBlockPatterns.length > 2 ) {
maxBlockTypesToShow = 0;
}

const filteredBlockTypes = useMemo( () => {
if ( maxBlockTypesToShow === 0 ) {
return [];
}
const results = searchBlockItems(
orderBy( blockTypes, [ 'frecency' ], [ 'desc' ] ),
blockTypeCategories,
Expand Down Expand Up @@ -166,14 +169,14 @@ function InserterSearchResults( {
<InserterListbox>
{ ! showBlockDirectory && ! hasItems && <InserterNoResults /> }

{ __experimentalPrioritizePatterns ? patternsUI : blocksUI }
{ prioritizePatterns ? patternsUI : blocksUI }

{ !! filteredBlockTypes.length &&
!! filteredBlockPatterns.length && (
<div className="block-editor-inserter__quick-inserter-separator" />
) }

{ __experimentalPrioritizePatterns ? blocksUI : patternsUI }
{ prioritizePatterns ? blocksUI : patternsUI }

{ showBlockDirectory && (
<__unstableInserterMenuExtension.Slot
Expand Down
2 changes: 1 addition & 1 deletion packages/edit-site/src/store/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export const getSettings = createSelector(
hasFixedToolbar: isFeatureActive( state, 'fixedToolbar' ),
__experimentalSetIsInserterOpened: setIsInserterOpen,
__experimentalReusableBlocks: getReusableBlocks( state ),
__experimentalPrioritizePatternsOnQuickInserterRoot:
__experimentalPreferPatternsOnRoot:
'wp_template' === getEditedPostType( state ),
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ function useBlockEditorSettings( settings, hasTemplate ) {
__experimentalCreatePageEntity: createPageEntity,
__experimentalUserCanCreatePages: userCanCreatePages,
pageOnFront,
__experimentalPrioritizePatternsOnQuickInserterRoot: hasTemplate,
__experimentalPreferPatternsOnRoot: hasTemplate,
} ),
[
settings,
Expand Down

0 comments on commit 460be3c

Please sign in to comment.