Skip to content

Commit

Permalink
[Query Loop]: Show variant patterns even if there are no patterns for…
Browse files Browse the repository at this point in the history
… the Query Loop block (#48793)
  • Loading branch information
ntsekouras authored and fabiankaegy committed Mar 6, 2023
1 parent cdf2da5 commit bfacf9b
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions packages/block-library/src/query/edit/query-placeholder.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { __ } from '@wordpress/i18n';
/**
* Internal dependencies
*/
import { useScopedBlockVariations } from '../utils';
import { useScopedBlockVariations, useBlockNameForPatterns } from '../utils';

export default function QueryPlaceholder( {
attributes,
Expand All @@ -30,22 +30,27 @@ export default function QueryPlaceholder( {
} ) {
const [ isStartingBlank, setIsStartingBlank ] = useState( false );
const blockProps = useBlockProps();
const blockNameForPatterns = useBlockNameForPatterns(
clientId,
attributes
);

const { blockType, allVariations, hasPatterns } = useSelect(
( select ) => {
const { getBlockVariations, getBlockType } = select( blocksStore );
const { getBlockRootClientId, getPatternsByBlockTypes } =
select( blockEditorStore );
const rootClientId = getBlockRootClientId( clientId );

return {
blockType: getBlockType( name ),
allVariations: getBlockVariations( name ),
hasPatterns: !! getPatternsByBlockTypes( name, rootClientId )
.length,
hasPatterns: !! getPatternsByBlockTypes(
blockNameForPatterns,
rootClientId
).length,
};
},
[ name, clientId ]
[ name, blockNameForPatterns, clientId ]
);

const matchingVariation = getMatchingVariation( attributes, allVariations );
Expand Down

0 comments on commit bfacf9b

Please sign in to comment.