diff --git a/packages/block-editor/src/components/inserter/block-patterns-explorer/patterns-list.js b/packages/block-editor/src/components/inserter/block-patterns-explorer/patterns-list.js index a33ceba422f68..32f52dd5c3818 100644 --- a/packages/block-editor/src/components/inserter/block-patterns-explorer/patterns-list.js +++ b/packages/block-editor/src/components/inserter/block-patterns-explorer/patterns-list.js @@ -74,7 +74,7 @@ function PatternList( { const [ destinationRootClientId, onInsertBlocks ] = useInsertionPoint( { shouldFocusBlock: true, } ); - const { patterns: allPatterns, onClickPattern } = usePatternsState( + const [ patterns, , onClickPattern ] = usePatternsState( onInsertBlocks, destinationRootClientId ); @@ -88,7 +88,7 @@ function PatternList( { ); const filteredBlockPatterns = useMemo( () => { - const filteredPatterns = allPatterns.filter( ( pattern ) => { + const filteredPatterns = patterns.filter( ( pattern ) => { if ( isPatternFiltered( pattern, @@ -127,7 +127,7 @@ function PatternList( { }, [ searchValue, patternSourceFilter, - allPatterns, + patterns, selectedCategory, registeredPatternCategories, patternSyncFilter, diff --git a/packages/block-editor/src/components/inserter/block-patterns-tab.js b/packages/block-editor/src/components/inserter/block-patterns-tab.js index 8e29567343fee..37192df28a23b 100644 --- a/packages/block-editor/src/components/inserter/block-patterns-tab.js +++ b/packages/block-editor/src/components/inserter/block-patterns-tab.js @@ -74,7 +74,7 @@ export function isPatternFiltered( pattern, sourceFilter, syncFilter ) { } export function usePatternsCategories( rootClientId, sourceFilter = 'all' ) { - const { patterns: allPatterns, allCategories } = usePatternsState( + const [ patterns, allCategories ] = usePatternsState( undefined, rootClientId ); @@ -82,12 +82,12 @@ export function usePatternsCategories( rootClientId, sourceFilter = 'all' ) { const filteredPatterns = useMemo( () => sourceFilter === 'all' - ? allPatterns - : allPatterns.filter( + ? patterns + : patterns.filter( ( pattern ) => ! isPatternFiltered( pattern, sourceFilter ) ), - [ sourceFilter, allPatterns ] + [ sourceFilter, patterns ] ); const hasRegisteredCategory = useCallback( @@ -192,7 +192,7 @@ export function BlockPatternsCategoryPanel( { showTitlesAsTooltip, patternFilter, } ) { - const { patterns: allPatterns, onClickPattern } = usePatternsState( + const [ allPatterns, , onClickPattern ] = usePatternsState( onInsert, rootClientId ); diff --git a/packages/block-editor/src/components/inserter/hooks/use-patterns-state.js b/packages/block-editor/src/components/inserter/hooks/use-patterns-state.js index 0c938b0474a9f..90d67ccf12190 100644 --- a/packages/block-editor/src/components/inserter/hooks/use-patterns-state.js +++ b/packages/block-editor/src/components/inserter/hooks/use-patterns-state.js @@ -80,7 +80,7 @@ const usePatternsState = ( onInsert, rootClientId ) => { [ createSuccessNotice, onInsert ] ); - return { patterns, allCategories, onClickPattern }; + return [ patterns, allCategories, onClickPattern ]; }; export default usePatternsState; diff --git a/packages/block-editor/src/components/inserter/quick-inserter.js b/packages/block-editor/src/components/inserter/quick-inserter.js index d75b45564246e..540b51a4757e0 100644 --- a/packages/block-editor/src/components/inserter/quick-inserter.js +++ b/packages/block-editor/src/components/inserter/quick-inserter.js @@ -46,7 +46,7 @@ export default function QuickInserter( { onInsertBlocks ); - const { patterns } = usePatternsState( + const [ patterns ] = usePatternsState( onInsertBlocks, destinationRootClientId ); diff --git a/packages/block-editor/src/components/inserter/search-results.js b/packages/block-editor/src/components/inserter/search-results.js index 46cacb1784647..23a3cafc563ba 100644 --- a/packages/block-editor/src/components/inserter/search-results.js +++ b/packages/block-editor/src/components/inserter/search-results.js @@ -81,7 +81,7 @@ function InserterSearchResults( { blockTypeCollections, onSelectBlockType, ] = useBlockTypesState( destinationRootClientId, onInsertBlocks ); - const { patterns, onClickPattern } = usePatternsState( + const [ patterns, , onClickPattern ] = usePatternsState( onInsertBlocks, destinationRootClientId );