Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(homepage-posts): post fetch for widget blocks #1066

Merged
merged 1 commit into from
Mar 16, 2022

Conversation

miguelpeixe
Copy link
Member

All Submissions:

Changes proposed in this Pull Request:

While adding a Homepage Posts or Carousel block to a widget area through the new block-based UI you get placeholder content instead of fetching actual posts.

This PR makes the necessary changes for these blocks to perform the posts fetch on the widget editor.

Current This PR
image image

How to test the changes in this Pull Request:

  1. If you are running Newspack plugin, check out fix: enable block-based widgets newspack-plugin#1550 to enable the block-based widget editor
  2. While on master, visit Appearance -> Widgets and place a Homepage Posts and a Carousel block
  3. Confirm you only see placeholder demo content
  4. Check out this branch, run npm run build and confirm the posts are fetched
  5. Edit a post/page and also add and edit the blocks to confirm there are no issues with its regular usage

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

@miguelpeixe miguelpeixe added bug Something isn't working [Status] Needs Review labels Mar 11, 2022
@miguelpeixe miguelpeixe requested a review from a team as a code owner March 11, 2022 14:47
@miguelpeixe miguelpeixe self-assigned this Mar 11, 2022
@@ -173,7 +173,8 @@ export const postsBlockSelector = ( select, { clientId, attributes } ) => {
const { getBlocks } = select( 'core/block-editor' );
const editorBlocksIds = getEditorBlocksIds( getEditorBlocks() );
Copy link
Member Author

Choose a reason for hiding this comment

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

getEditorBlocks() returns an empty array while in the widget editor, that's why another method for detecting the widget editor is used below.

Copy link
Member

@adekbadek adekbadek left a comment

Choose a reason for hiding this comment

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

👍

@miguelpeixe miguelpeixe merged commit 3734a3f into master Mar 16, 2022
@miguelpeixe miguelpeixe deleted the fix/homepage-block-widget branch March 16, 2022 13:28
matticbot pushed a commit that referenced this pull request Mar 31, 2022
# [1.47.0-alpha.1](v1.46.1...v1.47.0-alpha.1) (2022-03-31)

### Bug Fixes

* **author-list:** handle alphabetizing last names containing spaces ([#1057](#1057)) ([1af7e19](1af7e19))
* authors and guest authors in homepage posts ([#1083](#1083)) ([038d9a4](038d9a4))
* donate block non-default styles grid breakpoint ([#1078](#1078)) ([5450e57](5450e57))
* **homepage-posts:** post fetch for widget blocks ([#1066](#1066)) ([3734a3f](3734a3f))

### Features

* add alternate and minimal styles to donate block ([#1068](#1068)) ([3c914d2](3c914d2))
@matticbot
Copy link
Contributor

🎉 This PR is included in version 1.47.0-alpha.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

matticbot pushed a commit that referenced this pull request Apr 5, 2022
# [1.47.0](v1.46.1...v1.47.0) (2022-04-05)

### Bug Fixes

* **author-list:** handle alphabetizing last names containing spaces ([#1057](#1057)) ([1af7e19](1af7e19))
* authors and guest authors in homepage posts ([#1083](#1083)) ([038d9a4](038d9a4))
* donate block non-default styles grid breakpoint ([#1078](#1078)) ([5450e57](5450e57))
* **homepage-posts:** post fetch for widget blocks ([#1066](#1066)) ([3734a3f](3734a3f))
* incorrect nesting of tax_query args ([#1087](#1087)) ([a613874](a613874))

### Features

* add alternate and minimal styles to donate block ([#1068](#1068)) ([3c914d2](3c914d2))
@matticbot
Copy link
Contributor

🎉 This PR is included in version 1.47.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants