Skip to content

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

Open
laurelfulford wants to merge 1 commit into
releasefrom
fix/collections-missing-inner-blocks
Open

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

Conversation

@laurelfulford
Copy link
Copy Markdown
Contributor

@laurelfulford laurelfulford commented May 13, 2026

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).

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>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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
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.

2 participants