diff --git a/package-lock.json b/package-lock.json index b6be8b8fe..ac3db06ac 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,6 +12,7 @@ "dependencies": { "@stripe/stripe-js": "^1.24.0", "classnames": "^2.3.1", + "lodash": "^4.17.21", "newspack-components": "^2.0.3", "react": "^17.0.2", "redux": "^4.1.2", diff --git a/package.json b/package.json index 229e77474..ff2ed7b2d 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "dependencies": { "@stripe/stripe-js": "^1.24.0", "classnames": "^2.3.1", + "lodash": "^4.17.21", "newspack-components": "^2.0.3", "react": "^17.0.2", "redux": "^4.1.2", diff --git a/src/blocks/homepage-articles/store.js b/src/blocks/homepage-articles/store.js index b71a4c101..2d22a8e29 100644 --- a/src/blocks/homepage-articles/store.js +++ b/src/blocks/homepage-articles/store.js @@ -125,7 +125,17 @@ const createFetchPostsSaga = blockNames => { yield put( { type: 'DISABLE_UI' } ); - const blockQueries = getBlockQueries( getBlocks(), blockNames ); + // Ensure innerBlocks are populated for widget area blocks. + // See https://github.com/WordPress/gutenberg/issues/32607#issuecomment-890728216. + const blocks = getBlocks().map( block => { + const innerBlocks = select( 'core/block-editor' ).getBlocks( block.clientId ); + return { + ...block, + innerBlocks, + }; + } ); + + const blockQueries = getBlockQueries( blocks, blockNames ); // Use requested specific posts ids as the starting state of exclusion list. const specificPostsId = blockQueries.reduce( ( acc, { postsQuery } ) => { diff --git a/src/blocks/homepage-articles/utils.js b/src/blocks/homepage-articles/utils.js index 345cd2099..35e018af7 100644 --- a/src/blocks/homepage-articles/utils.js +++ b/src/blocks/homepage-articles/utils.js @@ -173,7 +173,8 @@ export const postsBlockSelector = ( select, { clientId, attributes } ) => { const { getBlocks } = select( 'core/block-editor' ); const editorBlocksIds = getEditorBlocksIds( getEditorBlocks() ); // The block might be rendered in the block styles preview, not in the editor. - const isEditorBlock = editorBlocksIds.indexOf( clientId ) >= 0; + const isWidgetEditor = getBlocks().some( block => block.name === 'core/widget-area' ); + const isEditorBlock = editorBlocksIds.indexOf( clientId ) >= 0 || isWidgetEditor; const { getPosts, getError, isUIDisabled } = select( STORE_NAMESPACE ); const props = {