Skip to content

Commit

Permalink
Update the query block to permit non-core interactive blocks (#60006)
Browse files Browse the repository at this point in the history
* updated the query block to permit non-core interactive blocks

* updated logic to correctly check all blocks inside the query support interactivity

* removed check for core blocks

* updated variable names and modal message per feedback

* renamed variable blockSupportsInteractivityBool to blockSupportsInteractivity

Unlinked contributors: poof86.

Co-authored-by: colinduwe <colind@git.wordpress.org>
Co-authored-by: cbravobernal <cbravobernal@git.wordpress.org>
Co-authored-by: gziolo <gziolo@git.wordpress.org>
Co-authored-by: sethrubenstein <smrubenstein@git.wordpress.org>
Co-authored-by: colorful-tones <colorful-tones@git.wordpress.org>
  • Loading branch information
6 people authored Apr 5, 2024
1 parent 7232cc4 commit 40e7a3b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default function EnhancedPaginationModal( {
if ( hasBlocksFromPlugins ) {
notice =
__(
'Currently, avoiding full page reloads is not possible when blocks from plugins are present inside the Query block.'
'Currently, avoiding full page reloads is not possible when non-interactive or non-clientNavigation compatible blocks from plugins are present inside the Query block.'
) +
' ' +
notice;
Expand Down
25 changes: 23 additions & 2 deletions packages/block-library/src/query/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ import { useMemo } from '@wordpress/element';
import { store as coreStore } from '@wordpress/core-data';
import { store as blockEditorStore } from '@wordpress/block-editor';
import { decodeEntities } from '@wordpress/html-entities';
import { cloneBlock, store as blocksStore } from '@wordpress/blocks';
import {
cloneBlock,
getBlockSupport,
store as blocksStore,
} from '@wordpress/blocks';

/** @typedef {import('@wordpress/blocks').WPBlockVariation} WPBlockVariation */

Expand Down Expand Up @@ -375,7 +379,24 @@ export const useUnsupportedBlocks = ( clientId ) => {
getClientIdsOfDescendants( clientId ).forEach(
( descendantClientId ) => {
const blockName = getBlockName( descendantClientId );
if ( ! blockName.startsWith( 'core/' ) ) {
/*
* Client side navigation can be true in two states:
* - supports.interactivity = true;
* - supports.interactivity.clientNavigation = true;
*/
const blockSupportsInteractivity = Object.is(
getBlockSupport( blockName, 'interactivity' ),
true
);
const blockSupportsInteractivityClientNavigation =
getBlockSupport(
blockName,
'interactivity.clientNavigation'
);
const blockInteractivity =
blockSupportsInteractivity ||
blockSupportsInteractivityClientNavigation;
if ( ! blockInteractivity ) {
blocks.hasBlocksFromPlugins = true;
} else if ( blockName === 'core/post-content' ) {
blocks.hasPostContentBlock = true;
Expand Down

0 comments on commit 40e7a3b

Please sign in to comment.