Skip to content

Release 1.8.1 — BLOCK-20 insert-child nesting fix#17

Merged
zackkatz merged 1 commit into
developfrom
release/1.8.1
May 22, 2026
Merged

Release 1.8.1 — BLOCK-20 insert-child nesting fix#17
zackkatz merged 1 commit into
developfrom
release/1.8.1

Conversation

@zackkatz
Copy link
Copy Markdown
Member

@zackkatz zackkatz commented May 22, 2026

Summary

  • Fixes BLOCK-20: pages built inside-out via `insert_blocks` + `edit_block_tree.insert-child` were rendering child blocks as top-level siblings on the front end while looking correct in the editor.
  • Self-closing container wrappers (e.g. `
    ` from an empty-children insert) parse back as a single unsplit `innerContent` string. The original insert-child splice landed the new null placeholder BEFORE that string, putting the child outside the wrapper at serialize time.
  • Fix normalises single-string wrappers into `[opening, closing]` before splicing, so the new null always falls between them.

Test plan

  • New `test_insert_child_nests_inside_self_closing_wrapper` — single wrapper case.
  • New `test_insert_child_nests_through_multiple_self_closing_wrappers` — multi-level columns + column + heading.
  • Full `BlockMutatorTest` suite passes locally.
  • Verify CI: lint, phpunit, mcp integration tests.

Release

  • Version bumped to 1.8.1 (`gk-block-api.php` + `GK_BLOCK_API_VERSION`).
  • `readme.txt` Upgrade Notice + Changelog entry added.
  • Tag `v1.8.1` already pushed to origin.

Fixes BLOCK-20.

Summary by CodeRabbit

  • Bug Fixes

    • Fixed rendering behavior for child blocks in nested container blocks (columns, groups, buttons) that were incorrectly appearing as top-level siblings instead of remaining nested inside their parent containers on the front end.
  • Documentation

    • Updated changelog and upgrade notices for version 1.8.1 release.

Review Change Stack

…(1.8.1)

A page built inside-out via insert_blocks + edit_block_tree.insert-child
rendered correctly in the editor but serialised with children as top-level
siblings on the front end. The wrapper would appear empty and the
"inner" blocks would render outside it.

Root cause: when a container is created with insert_blocks and
innerHTML="<div class=\"wp-block-columns\"></div>" and no children,
parse_blocks reads innerContent back as a single unsplit string
['<div class=\"wp-block-columns\"></div>']. The original insert-child
splice scanned backward for a closing-tag string and inserted the new
child's null placeholder at that index — but with only one string the
null landed BEFORE it, producing [null, '<div></div>']. serialize_blocks
then emitted [child]<div></div>, with the child OUTSIDE the wrapper.

Fix normalises single-string wrappers into [opening, closing] before
the splice, so the new null always falls between them and children
interleave correctly. Pure local change to Block_Mutator; no API or
contract shifts.

- Two new regression tests in BlockMutatorTest:
    * test_insert_child_nests_inside_self_closing_wrapper — single
      wrapper case (columns + one column).
    * test_insert_child_nests_through_multiple_self_closing_wrappers
      — multi-level case (columns + column + heading, mirroring the
      original BLOCK-20 repro).
- readme.txt changelog + upgrade notice updated.
- Version bumped to 1.8.1 in both plugin header and GK_BLOCK_API_VERSION.
@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 22, 2026

BLOCK-20

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 22, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 468c1518-15cd-480b-8d7d-9d34cd3c4538

📥 Commits

Reviewing files that changed from the base of the PR and between f91343d and f13b827.

📒 Files selected for processing (4)
  • wordpress-plugin/gk-block-api/gk-block-api.php
  • wordpress-plugin/gk-block-api/includes/class-block-mutator.php
  • wordpress-plugin/gk-block-api/readme.txt
  • wordpress-plugin/gk-block-api/tests/Block/BlockMutatorTest.php

Walkthrough

This patch release fixes a serialization bug in the insert-child operation where nested blocks were rendered as top-level siblings instead of inside their container wrappers. The core fix normalizes wrapper innerContent by splitting wrapper strings at tag boundaries before inserting null placeholders. Version is bumped to 1.8.1 with corresponding documentation updates.

Changes

Nested block serialization fix and release

Layer / File(s) Summary
insert-child wrapper normalization and tests
wordpress-plugin/gk-block-api/includes/class-block-mutator.php, wordpress-plugin/gk-block-api/tests/Block/BlockMutatorTest.php
Block_Mutator::mutate() now detects and normalizes container innerContent lacking null placeholders by splitting the wrapper string at the opening tag, ensuring subsequent null insertion places children inside wrappers. Two new regression tests validate single-level and multi-level self-closing wrapper nesting (columns → column → heading).
Version bump and release documentation
wordpress-plugin/gk-block-api/gk-block-api.php, wordpress-plugin/gk-block-api/readme.txt
Plugin version constants and readme stable tag updated to 1.8.1. Upgrade notice and changelog entries describe the fix for nested container blocks (columns, group, buttons) where children now serialize inside wrappers instead of as siblings.

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the primary change: a release/version bump for fixing the insert-child nesting issue (BLOCK-20).
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch release/1.8.1

Comment @coderabbitai help to get the list of available commands and usage tips.

@zackkatz zackkatz merged commit 56fa06e into develop May 22, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant