From da77818cb84805e18ed8cd4ff0511802420f9506 Mon Sep 17 00:00:00 2001 From: Glen Davies Date: Thu, 14 Sep 2023 10:57:47 +1200 Subject: [PATCH] Fix sync filter reset check --- .../components/inserter/block-patterns-explorer/explorer.js | 5 +---- .../src/components/inserter/block-patterns-tab.js | 3 +-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/packages/block-editor/src/components/inserter/block-patterns-explorer/explorer.js b/packages/block-editor/src/components/inserter/block-patterns-explorer/explorer.js index 78fc75c9c3a80d..4a4bcab3397aef 100644 --- a/packages/block-editor/src/components/inserter/block-patterns-explorer/explorer.js +++ b/packages/block-editor/src/components/inserter/block-patterns-explorer/explorer.js @@ -32,10 +32,7 @@ function PatternsExplorer( { initialCategory, rootClientId } ) { // If the sync filter changes, we need to select the "All" category to avoid // showing a confusing no results screen. useEffect( () => { - if ( - patternSyncFilter !== null && - previousSyncFilter !== patternSyncFilter - ) { + if ( patternSyncFilter && patternSyncFilter !== previousSyncFilter ) { setSelectedCategory( initialCategory?.name ); } }, [ 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 850cec3d4bdbb7..724b2468392763 100644 --- a/packages/block-editor/src/components/inserter/block-patterns-tab.js +++ b/packages/block-editor/src/components/inserter/block-patterns-tab.js @@ -318,8 +318,7 @@ function BlockPatternsTabs( { const previousSyncFilter = usePrevious( patternSyncFilter ); // If the sync filter changes, we need to select the "All" category to avoid - // showing a confusing no results screen. We also need to clear the category - // selection when the component unmounts. + // showing a confusing no results screen. useEffect( () => { if ( patternSyncFilter && patternSyncFilter !== previousSyncFilter ) { onSelectCategory( allPatternsCategory, patternSourceFilter );