Skip to content

Block bindings : add support to list-item#78947

Merged
cbravobernal merged 6 commits into
WordPress:trunkfrom
saulyz:feature/add-block-bindings-to-list
Jun 17, 2026
Merged

Block bindings : add support to list-item#78947
cbravobernal merged 6 commits into
WordPress:trunkfrom
saulyz:feature/add-block-bindings-to-list

Conversation

@saulyz

@saulyz saulyz commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

What?

Adds core/list-item to the block attributes supported by Block Bindings, so a List Item's content rich text can be bound to a source.

This is part of the List Item Block Bindings work, split into two PRs for review hygiene:

  1. This PR — clean enablement: the block_bindings_supported_attributes filter + basic (non-nested) tests. Lands first.
  2. Block Bindings: Preserve nested lists when binding List Item content #78991 — the render fix that preserves nested List inner blocks when a bound List Item also contains a nested list.

Why?

The List Item block had no Block Bindings support, so its content couldn't be driven by a source (custom sources, pattern overrides, etc.). Enabling content is a small, low-risk change. Preserving a nested List inside the same <li> when the content is bound is a separate render-side concern, handled in #78991, so this PR stays a clean enablement.

How?

Registers content as a supported binding attribute for core/list-item through the block_bindings_supported_attributes filter (compat shim in lib/compat/wordpress-7.1/block-bindings.php).

Adds phpunit coverage for the cases that need only the filter — no render changes: plain-text values, post-KSES sanitization, and inline-image/markup replacement. Nested-list preservation tests live with the fix in #78991.

Related

Testing Instructions

  1. Create a List with a List Item.
  2. Bind the List Item's content attribute to a source (e.g. a custom Block Bindings source, or a pattern override).
  3. Confirm the rendered List Item shows the bound value.

Or run the PHP unit tests:

npm run test:unit:php -- --filter list_item

Testing Instructions for Keyboard

N/A — no UI changes.

Use of AI Tools

The PR description and the basic phpunit tests were drafted with AI assistance (Claude Code) and reviewed by a maintainer. The filter implementation is the original contribution by @Sauliusv.

@cbravobernal cbravobernal added [Feature] Block bindings [Type] Feature New feature to highlight in changelogs. labels Jun 4, 2026
cbravobernal added a commit to cbravobernal/gutenberg that referenced this pull request Jun 6, 2026
Add server-side rendering support so a bound `core/list-item` content
attribute is replaced without dropping nested List inner blocks rendered
inside the same `<li>`.

All logic lives in the wordpress-7.1 compat layer: a `render_block_data`
filter hides the binding from Core's generic rich-text replacement, and a
`render_block` filter resolves the value through the existing
`gutenberg_process_block_bindings()` helper and applies it with a
nested-list-aware replacement. The shipped wordpress-6.9 block-bindings
code is left untouched and no new hooks are introduced.

Adds PHPUnit coverage (plain text, nested/ordered/deep lists, empty value,
pattern overrides, sanitization, non-list inner blocks) and an editor e2e
test.

Builds on WordPress#78947 (list-item block bindings support).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
cbravobernal added a commit to cbravobernal/gutenberg that referenced this pull request Jun 7, 2026
Add server-side rendering support so a bound `core/list-item` content
attribute is replaced without dropping nested List inner blocks rendered
inside the same `<li>`.

All logic lives in the wordpress-7.1 compat layer: a `render_block_data`
filter hides the binding from Core's generic rich-text replacement, and a
`render_block` filter resolves the value through the existing
`gutenberg_process_block_bindings()` helper and applies it with a
nested-list-aware replacement. The shipped wordpress-6.9 block-bindings
code is left untouched and no new hooks are introduced.

Adds PHPUnit coverage (plain text, nested/ordered/deep lists, empty value,
pattern overrides, sanitization, non-list inner blocks) and an editor e2e
test.

Builds on WordPress#78947 (list-item block bindings support).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
cbravobernal added a commit to cbravobernal/gutenberg that referenced this pull request Jun 9, 2026
Add server-side rendering support so a bound `core/list-item` content
attribute is replaced without dropping nested List inner blocks rendered
inside the same `<li>`.

All logic lives in the wordpress-7.1 compat layer: a `render_block_data`
filter hides the binding from Core's generic rich-text replacement, and a
`render_block` filter resolves the value through the existing
`gutenberg_process_block_bindings()` helper and applies it with a
nested-list-aware replacement. The shipped wordpress-6.9 block-bindings
code is left untouched and no new hooks are introduced.

Adds PHPUnit coverage (plain text, nested/ordered/deep lists, empty value,
pattern overrides, sanitization, non-list inner blocks) and an editor e2e
test.

Builds on WordPress#78947 (list-item block bindings support).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
cbravobernal added a commit to cbravobernal/gutenberg that referenced this pull request Jun 17, 2026
The non-nested List Item binding tests (plain text, sanitization, inline image)
exercise only the enablement filter and now live in WordPress#78947. Keep here the cases
that depend on the inner-block preservation workaround: nested lists, ordered
and deeply nested lists, empty values, non-list inner blocks and pattern
overrides.
@cbravobernal cbravobernal marked this pull request as ready for review June 17, 2026 12:53
@github-actions

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.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @[email protected].

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

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

Unlinked contributors: [email protected].

Co-authored-by: mirka <[email protected]>
Co-authored-by: cbravobernal <[email protected]>

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

mirka and others added 6 commits June 17, 2026 14:54
Add phpunit coverage for binding a List Item's content with non-nested values
(plain text, sanitized markup, inline image replacement). These exercise the
enablement filter alone and need no inner-block preservation.
@cbravobernal cbravobernal force-pushed the feature/add-block-bindings-to-list branch from 596e9c6 to c72b88e Compare June 17, 2026 12:55
@cbravobernal cbravobernal self-requested a review June 17, 2026 12:57

@cbravobernal cbravobernal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a follow-up PR to fix a bug we found while enabling this PR. As it also affects other blocks, we are doing in a separate PR for commit hygiene.

WordPress/wordpress-develop#12113

@cbravobernal cbravobernal enabled auto-merge (squash) June 17, 2026 12:59
@cbravobernal cbravobernal merged commit 34d09b7 into WordPress:trunk Jun 17, 2026
43 checks passed
@github-actions github-actions Bot added this to the Gutenberg 23.5 milestone Jun 17, 2026
@bgrgicak bgrgicak added [Type] Enhancement A suggestion for improvement. and removed [Type] Feature New feature to highlight in changelogs. labels Jun 24, 2026
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.

4 participants