Skip to content

Commit

Permalink
Pattern Explorer Modal: Select the first category as the initial cate…
Browse files Browse the repository at this point in the history
…gory (#47661)

* Pass the first pattern category as the initially selected category in the pattern explorer modal.

* If there is a selected category, make sure we use that instead.

* Update packages/block-editor/src/components/inserter/block-patterns-tab.js

Co-authored-by: George Mamadashvili <georgemamadashvili@gmail.com>

---------

Co-authored-by: George Mamadashvili <georgemamadashvili@gmail.com>
  • Loading branch information
apeatling and Mamaduka committed Feb 3, 2023
1 parent a817302 commit 8a15ceb
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ function BlockPatternsTabs( {
} ) {
const [ showPatternsExplorer, setShowPatternsExplorer ] = useState( false );
const categories = usePatternsCategories( rootClientId );
const initialCategory = selectedCategory || categories[ 0 ];
const isMobile = useViewportMatch( 'medium', '<' );
return (
<>
Expand Down Expand Up @@ -261,7 +262,7 @@ function BlockPatternsTabs( {
) }
{ showPatternsExplorer && (
<PatternsExplorerModal
initialCategory={ selectedCategory }
initialCategory={ initialCategory }
patternCategories={ categories }
onModalClose={ () => setShowPatternsExplorer( false ) }
/>
Expand Down

0 comments on commit 8a15ceb

Please sign in to comment.