Skip to content

Commit

Permalink
Query Pagination: Set 'clientId' as useSelect dependency (#52358)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamaduka committed Jul 6, 2023
1 parent 00cfeee commit 892f9a6
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions packages/block-library/src/query-pagination/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,23 @@ export default function QueryPaginationEdit( {
setAttributes,
clientId,
} ) {
const hasNextPreviousBlocks = useSelect( ( select ) => {
const { getBlocks } = select( blockEditorStore );
const innerBlocks = getBlocks( clientId );
/**
* Show the `paginationArrow` and `showLabel` controls only if a
* `QueryPaginationNext/Previous` block exists.
*/
return innerBlocks?.find( ( innerBlock ) => {
return [
'core/query-pagination-next',
'core/query-pagination-previous',
].includes( innerBlock.name );
} );
}, [] );
const hasNextPreviousBlocks = useSelect(
( select ) => {
const { getBlocks } = select( blockEditorStore );
const innerBlocks = getBlocks( clientId );
/**
* Show the `paginationArrow` and `showLabel` controls only if a
* `QueryPaginationNext/Previous` block exists.
*/
return innerBlocks?.find( ( innerBlock ) => {
return [
'core/query-pagination-next',
'core/query-pagination-previous',
].includes( innerBlock.name );
} );
},
[ clientId ]
);
const blockProps = useBlockProps();
const innerBlocksProps = useInnerBlocksProps( blockProps, {
template: TEMPLATE,
Expand Down

1 comment on commit 892f9a6

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 892f9a6.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5472892412
📝 Reported issues:

Please sign in to comment.