From 2026ae54175d7422933eaac0abce4dcc71f648f2 Mon Sep 17 00:00:00 2001 From: Luis Felipe Zaguini Date: Thu, 5 Sep 2024 10:10:18 -0300 Subject: [PATCH] Do not setMeta if there are no bound group blocks --- .../runtime/src/hooks/use-bound-group-extractor.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/includes/runtime/src/hooks/use-bound-group-extractor.js b/includes/runtime/src/hooks/use-bound-group-extractor.js index 0b31842..5109d98 100644 --- a/includes/runtime/src/hooks/use-bound-group-extractor.js +++ b/includes/runtime/src/hooks/use-bound-group-extractor.js @@ -11,7 +11,11 @@ export const useBoundGroupExtractor = () => { const [ , setMeta ] = useEntityProp( 'postType', POST_TYPE, 'meta' ); useEffect( () => { - const boundBlocks = findBoundBlocks( blocks ); + const boundBlocks = findBoundGroupBlocks( blocks ); + + if ( Object.keys( boundBlocks ).length === 0 ) { + return; + } setMeta( boundBlocks ); }, [ blocks, setMeta ] ); @@ -19,7 +23,7 @@ export const useBoundGroupExtractor = () => { return null; }; -const findBoundBlocks = ( blocks, acc = {} ) => { +const findBoundGroupBlocks = ( blocks, acc = {} ) => { for ( const block of blocks ) { if ( 'core/group' !== block.name ) { continue; @@ -32,7 +36,7 @@ const findBoundBlocks = ( blocks, acc = {} ) => { } if ( block.innerBlocks.length > 0 ) { - acc = findBoundBlocks( block.innerBlocks, acc ); + acc = findBoundGroupBlocks( block.innerBlocks, acc ); } }