From dd63911169a747e6e71a04bd96662e0eb6efc1bc Mon Sep 17 00:00:00 2001 From: Jorge Date: Mon, 14 Feb 2022 16:19:18 +0000 Subject: [PATCH] feedback --- .../src/components/inserter/quick-inserter.js | 6 +++--- .../src/components/inserter/search-results.js | 17 ++++++++++------- packages/edit-site/src/store/selectors.js | 2 +- .../provider/use-block-editor-settings.js | 2 +- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/packages/block-editor/src/components/inserter/quick-inserter.js b/packages/block-editor/src/components/inserter/quick-inserter.js index f3d0127a252400..d0f589e87955cd 100644 --- a/packages/block-editor/src/components/inserter/quick-inserter.js +++ b/packages/block-editor/src/components/inserter/quick-inserter.js @@ -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, }; }, @@ -128,7 +128,7 @@ export default function QuickInserter( { maxBlockPatterns={ maxBlockPatterns } maxBlockTypes={ SHOWN_BLOCK_TYPES } isDraggable={ false } - __experimentalPrioritizePatterns={ prioritizePatterns } + prioritizePatterns={ prioritizePatterns } /> diff --git a/packages/block-editor/src/components/inserter/search-results.js b/packages/block-editor/src/components/inserter/search-results.js index 264fcb74c1ccc3..dcdaea3a58a096 100644 --- a/packages/block-editor/src/components/inserter/search-results.js +++ b/packages/block-editor/src/components/inserter/search-results.js @@ -48,7 +48,7 @@ function InserterSearchResults( { showBlockDirectory = false, isDraggable = true, shouldFocusBlock = true, - __experimentalPrioritizePatterns, + prioritizePatterns, } ) { const debouncedSpeak = useDebounce( speak, 500 ); @@ -72,6 +72,9 @@ function InserterSearchResults( { ); const filteredBlockPatterns = useMemo( () => { + if ( maxBlockPatterns === 0 ) { + return []; + } const results = searchItems( patterns, filterValue ); return maxBlockPatterns !== undefined ? results.slice( 0, maxBlockPatterns ) @@ -79,14 +82,14 @@ function InserterSearchResults( { }, [ 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, @@ -166,14 +169,14 @@ function InserterSearchResults( { { ! showBlockDirectory && ! hasItems && } - { __experimentalPrioritizePatterns ? patternsUI : blocksUI } + { prioritizePatterns ? patternsUI : blocksUI } { !! filteredBlockTypes.length && !! filteredBlockPatterns.length && (
) } - { __experimentalPrioritizePatterns ? blocksUI : patternsUI } + { prioritizePatterns ? blocksUI : patternsUI } { showBlockDirectory && ( <__unstableInserterMenuExtension.Slot diff --git a/packages/edit-site/src/store/selectors.js b/packages/edit-site/src/store/selectors.js index 7b36b9b3a299cd..fc07bb7b77cd1d 100644 --- a/packages/edit-site/src/store/selectors.js +++ b/packages/edit-site/src/store/selectors.js @@ -98,7 +98,7 @@ export const getSettings = createSelector( hasFixedToolbar: isFeatureActive( state, 'fixedToolbar' ), __experimentalSetIsInserterOpened: setIsInserterOpen, __experimentalReusableBlocks: getReusableBlocks( state ), - __experimentalPrioritizePatternsOnQuickInserterRoot: + __experimentalPreferPatternsOnRoot: 'wp_template' === getEditedPostType( state ), }; diff --git a/packages/editor/src/components/provider/use-block-editor-settings.js b/packages/editor/src/components/provider/use-block-editor-settings.js index c8ceee4e9d3912..46c70c9bb3435a 100644 --- a/packages/editor/src/components/provider/use-block-editor-settings.js +++ b/packages/editor/src/components/provider/use-block-editor-settings.js @@ -148,7 +148,7 @@ function useBlockEditorSettings( settings, hasTemplate ) { __experimentalCreatePageEntity: createPageEntity, __experimentalUserCanCreatePages: userCanCreatePages, pageOnFront, - __experimentalPrioritizePatternsOnQuickInserterRoot: hasTemplate, + __experimentalPreferPatternsOnRoot: hasTemplate, } ), [ settings,