Skip to content

Commit a75cccf

Browse files
committed
Revert the update to paging scroll to top
1 parent 42e8aa1 commit a75cccf

File tree

2 files changed

+16
-21
lines changed

2 files changed

+16
-21
lines changed

packages/block-editor/src/components/block-patterns-list/index.js

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import classnames from 'classnames';
66
/**
77
* WordPress dependencies
88
*/
9-
import { useState, useRef } from '@wordpress/element';
9+
import { useState } from '@wordpress/element';
1010
import {
1111
VisuallyHidden,
1212
__unstableComposite as Composite,
@@ -25,7 +25,6 @@ import { Icon, symbol } from '@wordpress/icons';
2525
import BlockPreview from '../block-preview';
2626
import InserterDraggableBlocks from '../inserter-draggable-blocks';
2727
import BlockPatternsPaging from '../block-patterns-paging';
28-
import usePatternsPaging from '../inserter/hooks/use-patterns-paging';
2928

3029
const WithToolTip = ( { showTooltip, title, children } ) => {
3130
if ( showTooltip ) {
@@ -144,31 +143,18 @@ function BlockPatternPlaceholder() {
144143

145144
function BlockPatternList( {
146145
isDraggable,
146+
blockPatterns,
147+
shownPatterns,
147148
onHover,
148149
onClickPattern,
149150
orientation,
150151
label = __( 'Block Patterns' ),
151152
showTitlesAsTooltip,
152-
currentCategoryPatterns,
153-
category,
154-
patternFilter,
153+
pagingProps,
155154
} ) {
156155
const composite = useCompositeState( { orientation } );
157-
const container = useRef();
158-
const pagingProps = usePatternsPaging(
159-
currentCategoryPatterns,
160-
category,
161-
container,
162-
patternFilter
163-
);
164-
const {
165-
categoryPatternsAsyncList: shownPatterns,
166-
categoryPatterns: blockPatterns,
167-
} = pagingProps;
168-
169156
return (
170157
<Composite
171-
ref={ container }
172158
{ ...composite }
173159
role="listbox"
174160
className="block-editor-block-patterns-list"
@@ -190,7 +176,7 @@ function BlockPatternList( {
190176
<BlockPatternPlaceholder key={ pattern.name } />
191177
);
192178
} ) }
193-
{ pagingProps.numPages > 1 && (
179+
{ pagingProps && pagingProps.numPages > 1 && (
194180
<BlockPatternsPaging { ...pagingProps } />
195181
) }
196182
</Composite>

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import usePatternsState from './hooks/use-patterns-state';
3131
import BlockPatternList from '../block-patterns-list';
3232
import PatternsExplorerModal from './block-patterns-explorer/explorer';
3333
import MobileTabNavigation from './mobile-tab-navigation';
34+
import usePatternsPaging from './hooks/use-patterns-paging';
3435
import {
3536
BlockPatternsSyncFilter,
3637
SYNC_TYPES,
@@ -261,6 +262,12 @@ export function BlockPatternsCategoryPanel( {
261262
]
262263
);
263264

265+
const pagingProps = usePatternsPaging(
266+
currentCategoryPatterns,
267+
category,
268+
container
269+
);
270+
264271
// Hide block pattern preview on unmount.
265272
// eslint-disable-next-line react-hooks/exhaustive-deps
266273
useEffect( () => () => onHover( null ), [] );
@@ -302,15 +309,17 @@ export function BlockPatternsCategoryPanel( {
302309

303310
{ currentCategoryPatterns.length > 0 && (
304311
<BlockPatternList
305-
currentCategoryPatterns={ currentCategoryPatterns }
306-
category={ category }
312+
shownPatterns={ pagingProps.categoryPatternsAsyncList }
313+
blockPatterns={ pagingProps.categoryPatterns }
307314
onClickPattern={ onClickPattern }
308315
onHover={ onHover }
309316
label={ category.label }
310317
orientation="vertical"
318+
category={ category.name }
311319
isDraggable
312320
showTitlesAsTooltip={ showTitlesAsTooltip }
313321
patternFilter={ patternSourceFilter }
322+
pagingProps={ pagingProps }
314323
/>
315324
) }
316325
</div>

0 commit comments

Comments
 (0)