Skip to content

Explain empty block bindings field list and hide unbindable fields - #606

Open
the-hercules wants to merge 1 commit into
WordPress:trunkfrom
the-hercules:fix/600-bindings-field-picker-hint
Open

the-hercules wants to merge 1 commit into
WordPress:trunkfrom
the-hercules:fix/600-bindings-field-picker-hint

Conversation

@the-hercules

Copy link
Copy Markdown

With default settings, the block editor's "Connect to a field" panel didn't appear at all, because field groups have Show in REST API off. Once that was on, the picker listed fields with "Allow Access to Value in Editor UI" off, which render empty on the front end once bound. Nothing in the UI explained either requirement.

This PR:

  • Shows a hint in the "Connect to a field" panel when the post has field groups but none of their fields can be bound to the selected block. It names both settings and the field types the block accepts, and links to the field groups screen for users who can manage SCF.
  • Hides fields with "Allow Access to Value in Editor UI" off from the default-mode picker (post and site editor), matching the datastore-mode picker. The REST _source data and the scf_field_groups types endpoint now include allow_in_bindings.
  • Hides fields without a name. Selecting one crashed the block: the empty value made core's updateBlockBindings() store { content: undefined }. An empty value for an unbound attribute is now ignored.
  • Adds a line under "Allow Access to Value in Editor UI" saying the field group also needs Show in REST API (only when the datastore is off).

Closes #600

Testing

  1. Create a field group with a Text field located on Posts, leaving all defaults. Edit a post and select a Paragraph block: the panel shows the hint (on trunk, no panel appears).
  2. Turn on Show in REST API on the field group: still the hint, because Allow Access is off (on trunk, the field is listed but renders empty once bound).
  3. Turn on Allow Access to Value in Editor UI: the field is listed, and once bound it renders on the front end.
  4. Open the field's settings: the Show in REST API line appears under the Allow Access toggle.

Automated: new Jest tests in tests/js/bindings/block-editor-panel.test.js and utils.test.js, and new PHPUnit tests for allow_in_bindings in the REST and types endpoint tests. The JS and PHPUnit suites and PHPStan pass locally.

Use of AI Tools

Written with Claude Code (Claude Opus 5.5), reviewed and tested by me.

…dable fields

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

Block bindings: "Connect to a field" is empty with default settings and gives no hint why

1 participant