From 5951dad7e22d5786bfb035cbbdafb6e0cb63733b Mon Sep 17 00:00:00 2001 From: Glen Davies Date: Tue, 12 Sep 2023 21:45:30 +1200 Subject: [PATCH] Fix issue with all category auto opening when tab first opened --- .../block-patterns-explorer/explorer.js | 21 +------------------ .../components/inserter/block-patterns-tab.js | 19 +---------------- 2 files changed, 2 insertions(+), 38 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..9f91433690fc87 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 @@ -2,10 +2,9 @@ * WordPress dependencies */ import { Modal } from '@wordpress/components'; -import { useState, useEffect } from '@wordpress/element'; +import { useState } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; import { useSelect } from '@wordpress/data'; -import { usePrevious } from '@wordpress/compose'; /** * Internal dependencies @@ -27,24 +26,6 @@ function PatternsExplorer( { initialCategory, rootClientId } ) { initialCategory?.name ); - const previousSyncFilter = usePrevious( patternSyncFilter ); - - // 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 - ) { - setSelectedCategory( initialCategory?.name ); - } - }, [ - patternSyncFilter, - previousSyncFilter, - patternSourceFilter, - initialCategory?.name, - ] ); - const patternCategories = usePatternsCategories( rootClientId, patternSourceFilter, 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 587692faf91124..a4aa8a84161885 100644 --- a/packages/block-editor/src/components/inserter/block-patterns-tab.js +++ b/packages/block-editor/src/components/inserter/block-patterns-tab.js @@ -9,7 +9,7 @@ import { useEffect, } from '@wordpress/element'; import { _x, __, _n, isRTL, sprintf } from '@wordpress/i18n'; -import { useViewportMatch, usePrevious } from '@wordpress/compose'; +import { useViewportMatch } from '@wordpress/compose'; import { __experimentalItemGroup as ItemGroup, __experimentalItem as Item, @@ -315,23 +315,6 @@ function BlockPatternsTabs( { const settings = getSettings(); return settings.patternsSyncFilter || 'all'; }, [] ); - const previousSyncFilter = usePrevious( patternSyncFilter ); - - // 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 - ) { - onSelectCategory( allPatternsCategory, patternSourceFilter ); - } - }, [ - patternSyncFilter, - previousSyncFilter, - onSelectCategory, - patternSourceFilter, - ] ); const categories = usePatternsCategories( rootClientId,