Skip to content

Release 1.8.1 → main: BLOCK-20 insert-child nesting fix#18

Merged
zackkatz merged 2 commits into
mainfrom
develop
May 22, 2026
Merged

Release 1.8.1 → main: BLOCK-20 insert-child nesting fix#18
zackkatz merged 2 commits into
mainfrom
develop

Conversation

@zackkatz
Copy link
Copy Markdown
Member

@zackkatz zackkatz commented May 22, 2026

Promotes the BLOCK-20 fix from `develop` to `main` for release.

Summary

  • Fixes nested container blocks (columns, columns/column, group, buttons, etc.) rendering their children as top-level siblings on the front end while looking correct in the editor.
  • Pages built inside-out via `insert_blocks` + `edit_block_tree.insert-child` now serialise with children correctly nested inside their wrappers.

What's included

Root cause

Containers created with `insert_blocks(innerHTML="<div…>", innerBlocks=[])` parse back with `innerContent` stored as a single unsplit string. The original `insert-child` splice landed the null placeholder BEFORE that string, so `serialize_blocks` emitted children OUTSIDE the wrapper. The fix normalises single-string wrappers into `[opening, closing]` before the splice.

Test plan

  • All Tests checks green on PR Release 1.8.1 — BLOCK-20 insert-child nesting fix #17 (PHPUnit on PHP 7.4 / 8.2 / 8.3 / 8.4 + Vitest + Build).
  • Two new regression tests in `BlockMutatorTest`:
    • `test_insert_child_nests_inside_self_closing_wrapper` (single wrapper).
    • `test_insert_child_nests_through_multiple_self_closing_wrappers` (columns + column + heading).
  • CI on this PR re-runs the full suite against main's base.

Release artifacts

  • `v1.8.1` tag already pushed to origin, points at `f13b827`. Once this merges, the tag will be reachable from `main` as well as `develop`.
  • `readme.txt` carries the 1.8.1 Upgrade Notice + Changelog entry for WordPress.org.

Summary by CodeRabbit

Release Notes - Version 1.8.1

  • Bug Fixes

    • Fixed nested container blocks rendering their children as top-level siblings on the front end; children now correctly display inside wrapper elements as intended.
  • Chores

    • Version bump to 1.8.1

Review Change Stack

zackkatz added 2 commits May 22, 2026 12:54
…(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.
Release 1.8.1 — BLOCK-20 insert-child nesting fix
@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: 175d4d92-e7c6-4dc3-8d6a-88baf416fe62

📥 Commits

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

📒 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 PR bumps the plugin to version 1.8.1 and fixes a serialization bug where nested container blocks created via insert-child rendered their children as top-level siblings instead of inside the wrapper. The fix normalizes self-closing container innerContent into split opening/closing entries before inserting child placeholders, ensuring correct nesting in output markup.

Changes

Nested Container Insertion Fix and Version 1.8.1 Release

Layer / File(s) Summary
insert-child wrapper innerContent normalization
wordpress-plugin/gk-block-api/includes/class-block-mutator.php
When inserting a child block, if the target wrapper's innerContent contains an unsplit self-closing structure (opening and closing tags in a single string), the code now detects this and splits it into separate opening and closing string entries before splicing the null placeholder, ensuring the child is nested inside the wrapper during serialization.
Regression tests for nested container insertion
wordpress-plugin/gk-block-api/tests/Block/BlockMutatorTest.php
Two new test methods verify single-level and multi-level insert-child nesting through self-closing wrappers (columns → column → heading), asserting correct innerContent splitting, innerBlocks counts, and serialized markup ordering with children inside their wrappers.
Version 1.8.1 release documentation and metadata
wordpress-plugin/gk-block-api/gk-block-api.php, wordpress-plugin/gk-block-api/readme.txt
Plugin version constant, header, readme stable tag, changelog, and upgrade notice all updated to 1.8.1, documenting the nested container serialization fix.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Possibly related PRs

  • GravityKit/block-mcp#17: Implements the same Block_Mutator::mutate() insert-child normalization fix with identical regression tests and 1.8.1 release metadata.
🚥 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 describes the main change: releasing version 1.8.1 with a fix for the insert-child nesting bug (BLOCK-20), which aligns with all the changeset modifications including version bumps, the core mutator fix, regression tests, and documentation updates.
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 develop

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

@zackkatz zackkatz merged commit 416dbac into main May 22, 2026
7 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