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-articles block not parsing nested inner blocks #1878

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from

Conversation

kevin940726
Copy link
Member

@kevin940726 kevin940726 commented Sep 10, 2024

All Submissions:

Changes proposed in this Pull Request:

Related to Automattic/wp-calypso#91839. This will also need a sync to https://github.com/Automattic/jetpack.

The Homepage Posts block (or the Blog Posts block in calypso and jetpack) won't load in the site editor. This is because the block fails to discover itself with getBlocks. This was partially fixed in #1066 but didn't take nested inner blocks into accounts. Since the core/post-content block is similar, this PR recursively calls getBlocks on all nested inner blocks.

How to test the changes in this Pull Request:

Test with wp-now locally:

  1. Switch to this branch and run npm install.
  2. Run npm start to build the blocks locally.
  3. Run npx @wp-now/wp-now start, it should open a webpage.
  4. Go to Pages -> Sample Page.
  5. Add a Homepage Posts block at the end of the page and expect it to display correctly.
  6. Save the page. Then, go to Appearance -> Editor -> Pages -> Sample Page to open the same page in the site editor.
  7. Expect the block to display correctly in the site editor as well.

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?

@kevin940726 kevin940726 changed the title Fix articles block fail to get all inner blocks Fix homepage-articles block not parsing nested inner blocks Sep 10, 2024
Copy link
Member

@andrewserong andrewserong left a comment

Choose a reason for hiding this comment

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

Nice work fixing this @kevin940726! I could reproduce the issue, where the block was stuck in a loading state when viewed while editing a page within the site editor. With this PR applied, the loading state concludes and the block renders as expected in the site editor 👍

Before After
image image

The approach for recursively getting blocks sounds good to me, but it'd be good to get a second review / approval from @Automattic/newspack-product too 🙂

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