Skip to content

Block Bindings: Preserve nested lists when binding List Item content - #78991

Closed
cbravobernal wants to merge 7 commits into
WordPress:trunkfrom
cbravobernal:add/list-item-block-bindings-v2
Closed

cbravobernal wants to merge 7 commits into
WordPress:trunkfrom
cbravobernal:add/list-item-block-bindings-v2

Conversation

@cbravobernal

@cbravobernal cbravobernal commented Jun 6, 2026 •

Copy link
Copy Markdown
Contributor

Part of the List Item block bindings work, split for review hygiene into two PRs (mirroring the Core split on Trac #65406):

  1. Enablement — Block bindings : add support to list-item #78947 registers core/list-item content as a bindable attribute (the block_bindings_supported_attributes filter). This corresponds to wordpress-develop#12204.
  2. This PR — the render-side Gutenberg compat fix: a List Item keeps its rich text and a nested List inside the same <li>, and the generic binding replacement in WordPress versions before 7.1 would drop the nested list. This corresponds to wordpress-develop#12113.

Relationship to Core

Both Core PRs are merged for WordPress 7.1:

  • wordpress-develop#12204 — core/list-item enablement in Core.
  • wordpress-develop#12113 — generic WP_Block::replace_html() inner-blocks preservation.

This PR keeps the Gutenberg plugin working on WordPress versions before 7.1 by re-appending rendered List Item inner blocks only when Core's binding replacement dropped them. On Core versions that already preserve the inner blocks, the workaround is a no-op because the nested rendered HTML is already present.

The workaround can be removed once the Gutenberg plugin's minimum required WordPress version is 7.1.

Use of AI Tools

AI tools (OpenAI Codex/ChatGPT) were used to help inspect the codebase, simplify the workaround, resolve conflicts, update PR metadata, and run or interpret local checks. The final code, tests, and PR updates were human-directed and reviewed by the PR author.

@github-actions

github-actions Bot commented Jun 6, 2026 •

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: cbravobernal <cbravobernal@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@cbravobernal cbravobernal added the [Type] Enhancement A suggestion for improvement. label Jun 6, 2026
@cbravobernal
cbravobernal marked this pull request as draft June 6, 2026 13:57
@cbravobernal
cbravobernal force-pushed the add/list-item-block-bindings-v2 branch from 6bcecfa to dab2d81 Compare June 7, 2026 09:58
@cbravobernal cbravobernal added the No Core Sync Required Indicates that any changes do not need to be synced to WordPress Core label Jun 8, 2026
@cbravobernal
cbravobernal force-pushed the add/list-item-block-bindings-v2 branch from d4ae1c6 to 85e57e3 Compare June 9, 2026 15:21
@cbravobernal cbravobernal changed the title Block Bindings: Add list item content support Block Bindings: Preserve nested lists when binding List Item content Jun 17, 2026
On WordPress versions without the WP_Block::replace_html() inner-blocks fix
(wordpress-develop#12113), binding a List Item's content replaces the whole
<li> and drops the nested List. The inner blocks remain on the instance, so
re-append them after Core applies the binding.

Replaces the previous ~500-line workaround (render_block_data stashing, a custom
WP_HTML_Processor subclass and ReflectionMethod feature detection) now that Core
resolves the binding value itself.
phpunit cases for nested, ordered, deeply nested, empty-value, raw-markup,
non-list inner block and pattern-override bindings, plus e2e coverage.
@cbravobernal
cbravobernal force-pushed the add/list-item-block-bindings-v2 branch from 2edcb8d to 0349712 Compare June 19, 2026 09:19
@cbravobernal
cbravobernal marked this pull request as ready for review June 19, 2026 10:39
@cbravobernal cbravobernal self-assigned this Jun 19, 2026
@cbravobernal cbravobernal removed the No Core Sync Required Indicates that any changes do not need to be synced to WordPress Core label Jun 19, 2026
@cbravobernal

Copy link
Copy Markdown
Contributor Author

Superseded by #79346, which uses the WordPress/gutenberg origin branch as the PR head.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants