Skip to content

fix(collections): restore list items in posts with card indicator#4726

Closed
laurelfulford wants to merge 3 commits into
releasefrom
fix/collections-missing-inner-blocks
Closed

fix(collections): restore list items in posts with card indicator#4726
laurelfulford wants to merge 3 commits into
releasefrom
fix/collections-missing-inner-blocks

Conversation

@laurelfulford

@laurelfulford laurelfulford commented May 13, 2026

Copy link
Copy Markdown
Contributor

All Submissions:

Changes proposed in this Pull Request:

In Collections, the 'Card' Collection Indicator Style used $block['innerHTML']; to grab each block in the content, which accidentally dropped inner blocks like <li> in List blocks, or columns in Columns blocks.

This hotfix switches it to use render_block( $block ); to preserve the inner blocks; it also adds a test for this specific case (making sure nested child blocks are preserved).

Edited to add: this PR also includes a fix for a failing PHP test - in WP 7.0, the markup for paragraphs changed to add a wp-block-paragraph CSS class, the Collections test should now reflect that, too.

Closes NPPM-2831

How to test the changes in this Pull Request:

  1. On a site running Collections, navigate to Newspack > Settings > Collections, and switch the 'Collection Indicator Style' to 'Card':
CleanShot 2026-05-13 at 13 44 29
  1. Create a new post with a List block and some list items in it. Publish.
  2. View the post on the front-end; note that the list doesn't appear.
  3. Inspect the post content using the element inspector - note that the empty <ul> tags still exist, just the list items do not.
  4. Apply this PR.
  5. Refresh your post; confirm that your list items appear.
  6. Smoke test and confirm the post otherwise looks okay.

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?

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Hotfix for Collections "Card" indicator style that was stripping inner blocks (e.g. <li> items in list blocks) by using $block['innerHTML'] instead of render_block().

Changes:

  • Switch reassembly in Content_Inserter::insert_after_nth_block from innerHTML to render_block() so inner/dynamic blocks render correctly.
  • Add a regression test exercising a core/list with core/list-item children.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
includes/collections/class-content-inserter.php Use render_block() to preserve inner-block content when reassembling parsed blocks.
tests/unit-tests/collections/class-test-content-inserter.php Adds regression test verifying list items survive insertion.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@laurelfulford laurelfulford marked this pull request as ready for review May 13, 2026 20:54
@laurelfulford laurelfulford requested a review from a team as a code owner May 13, 2026 20:54
@laurelfulford laurelfulford added the [Status] Needs Review The issue or pull request needs to be reviewed label May 13, 2026
@laurelfulford laurelfulford force-pushed the fix/collections-missing-inner-blocks branch from 85a5c9b to 02a4039 Compare May 28, 2026 19:27
@adekbadek

Copy link
Copy Markdown
Member

Closing in favour of the monorepo: Automattic/newspack-workspace#407.

This fix was needed but the legacy newspack-plugin repo is no longer the primary release source – the monorepo (newspack-workspace) is, and it currently ships a newer newspack-plugin (6.43.x) that still had this exact bug unfixed. Merging here alone wouldn't have reached sites running the monorepo build.

#407 carries your change over verbatim (render_block( $block ) + the inner-blocks regression test + the WP 7.0 wp-block-paragraph assertion update), still closing NPPM-2831. It's been verified in an isolated env: unit red/green (the regression test fails on the old innerHTML code with an empty <ul>, passes with the fix), the full Content_Inserter suite (14 tests) green, and an end-to-end front-end check confirming the Card indicator's list items survive (0 items before, 3 after). Full credit for the fix is yours – co-authored on the monorepo commit.

@adekbadek adekbadek closed this Jun 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Status] Needs Review The issue or pull request needs to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants