Release 1.8.1 — BLOCK-20 insert-child nesting fix#17
Conversation
…(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.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
WalkthroughThis patch release fixes a serialization bug in the ChangesNested block serialization fix and release
🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Summary
Test plan
Release
Fixes BLOCK-20.
Summary by CodeRabbit
Bug Fixes
Documentation