-
- { category.label }
-
-
{ category.description }
- { patternFilter === PATTERN_TYPES.user && (
-
- ) }
- { ! currentCategoryPatterns.length && (
-
{ __( 'No results found' ) }
- ) }
+
+
+
+
+
+ { category.label }
+
+
+
+
+ { category.description && (
+ { category.description }
+ ) }
+ { ! currentCategoryPatterns.length && (
+
+ { __( 'No results found' ) }
+
+ ) }
+
+
{ currentCategoryPatterns.length > 0 && (
) }
- { pagingProps.numPages > 1 && (
-
- ) }
);
}
@@ -300,12 +332,8 @@ function BlockPatternsTabs( {
rootClientId,
} ) {
const [ showPatternsExplorer, setShowPatternsExplorer ] = useState( false );
- const [ patternSourceFilter, setPatternSourceFilter ] = useState( 'all' );
- const categories = usePatternsCategories(
- rootClientId,
- patternSourceFilter
- );
+ const categories = usePatternsCategories( rootClientId );
const initialCategory = selectedCategory || categories[ 0 ];
const isMobile = useViewportMatch( 'medium', '<' );
@@ -317,23 +345,13 @@ function BlockPatternsTabs( {
aria-label={ __( 'Block pattern categories' ) }
className="block-editor-inserter__block-patterns-tabs"
>
-
{
- setPatternSourceFilter( value );
- onSelectCategory( allPatternsCategory, value );
- } }
- />
{ categories.map( ( category ) => (
-
- onSelectCategory(
- category,
- patternSourceFilter
- )
+ onSelectCategory( category )
}
className={
category === selectedCategory
diff --git a/packages/block-editor/src/components/inserter/hooks/use-patterns-paging.js b/packages/block-editor/src/components/inserter/hooks/use-patterns-paging.js
index 02df0f2ca053e..931796acceeb0 100644
--- a/packages/block-editor/src/components/inserter/hooks/use-patterns-paging.js
+++ b/packages/block-editor/src/components/inserter/hooks/use-patterns-paging.js
@@ -1,7 +1,7 @@
/**
* WordPress dependencies
*/
-import { useMemo, useState } from '@wordpress/element';
+import { useMemo, useState, useEffect } from '@wordpress/element';
import { useAsyncList, usePrevious } from '@wordpress/compose';
import { getScrollContainer } from '@wordpress/dom';
@@ -54,6 +54,17 @@ export default function usePatternsPaging(
setCurrentPage( page );
};
+
+ useEffect(
+ function scrollToTopOnCategoryChange() {
+ const scrollContainer = getScrollContainer(
+ scrollContainerRef?.current
+ );
+ scrollContainer?.scrollTo( 0, 0 );
+ },
+ [ currentCategory, scrollContainerRef ]
+ );
+
return {
totalItems,
categoryPatterns,
diff --git a/packages/block-editor/src/components/inserter/style.scss b/packages/block-editor/src/components/inserter/style.scss
index 756a5f7000a04..2528139e8f30f 100644
--- a/packages/block-editor/src/components/inserter/style.scss
+++ b/packages/block-editor/src/components/inserter/style.scss
@@ -299,13 +299,10 @@ $block-inserter-tabs-height: 44px;
border-left: $border-width solid $gray-200;
border-right: $border-width solid $gray-200;
position: absolute;
- padding: $grid-unit-40 $grid-unit-30;
top: 0;
left: 0;
height: 100%;
width: 100%;
- overflow-y: auto;
- scrollbar-gutter: stable both-edges;
@include break-medium {
left: 100%;
@@ -314,7 +311,10 @@ $block-inserter-tabs-height: 44px;
}
.block-editor-block-patterns-list {
- margin-top: $grid-unit-30;
+ overflow-y: auto;
+ flex-grow: 1;
+ height: 100%;
+ padding: $grid-unit-40 $grid-unit-30;
}
}
@@ -331,10 +331,18 @@ $block-inserter-tabs-height: 44px;
.block-editor-inserter__patterns-category-panel {
padding: 0 $grid-unit-20;
-
+ display: flex;
+ flex-direction: column;
+ height: 100%;
@include break-medium {
padding: 0;
}
+ .block-editor-inserter__patterns-category-panel-header {
+ padding: 16px $grid-unit-30;
+ }
+ .block-editor-inserter__patterns-category-no-results {
+ margin-top: $grid-unit-30;
+ }
}
.block-editor-inserter__preview-content {