Skip to content

Commit

Permalink
Fix label on open
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix authored and scruffian committed May 10, 2024
1 parent 132a00d commit 299e7d4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { useSelect } from '@wordpress/data';
import PatternsExplorerModal from '../block-patterns-explorer';
import MobileTabNavigation from '../mobile-tab-navigation';
import { PatternCategoryPreviews } from './pattern-category-previews';
import { usePatternCategories } from './use-pattern-categories';
import CategoryTabs from '../category-tabs';
import InserterNoResults from '../no-results';
import { store as blockEditorStore } from '../../../store';
Expand All @@ -22,14 +21,12 @@ import { unlock } from '../../../lock-unlock';
function BlockPatternsTab( {
onSelectCategory,
selectedCategory,
categories,
onInsert,
rootClientId,
children,
} ) {
const [ showPatternsExplorer, setShowPatternsExplorer ] = useState( false );

const categories = usePatternCategories( rootClientId );

const isMobile = useViewportMatch( 'medium', '<' );
const isResolvingPatterns = useSelect(
( select ) =>
Expand Down
11 changes: 8 additions & 3 deletions packages/block-editor/src/components/inserter/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import useInsertionPoint from './hooks/use-insertion-point';
import InserterTabs from './tabs';
import { useZoomOut } from '../../hooks/use-zoom-out';
import { store as blockEditorStore } from '../../store';
import { usePatternCategories } from './block-patterns-tab/use-pattern-categories';

const NOOP = () => {};
function InserterMenu(
Expand Down Expand Up @@ -61,9 +62,12 @@ function InserterMenu(
const [ filterValue, setFilterValue, delayedFilterValue ] =
useDebouncedInput( __experimentalFilterValue );
const [ hoveredItem, setHoveredItem ] = useState( null );
const [ selectedPatternCategory, setSelectedPatternCategory ] = useState( {
name: __experimentalInitialCategory,
} );
const categories = usePatternCategories( rootClientId );
const [ selectedPatternCategory, setSelectedPatternCategory ] = useState(
categories.find(
( category ) => category.name === __experimentalInitialCategory
)
);
const [ patternFilter, setPatternFilter ] = useState( 'all' );
const [ selectedMediaCategory, setSelectedMediaCategory ] =
useState( null );
Expand Down Expand Up @@ -219,6 +223,7 @@ function InserterMenu(
onInsert={ onInsertPattern }
onSelectCategory={ onClickPatternCategory }
selectedCategory={ selectedPatternCategory }
categories={ categories }
>
{ showPatternPanel && (
<PatternCategoryPreviewPanel
Expand Down

0 comments on commit 299e7d4

Please sign in to comment.