V3 block default field values not saved on first save when only InnerBlocks are edited (autoInlineEditing: true) — regression since 6.6.2 fix
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 55/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- php
- 领域
- full-stack
调研方向
使用所示的 block.json、my-block.php,以及包含布局默认值的导出字段组重现该问题。首先比较仅 InnerBlocks 发生变化时首次保存的区块属性和序列化内容,同时检查 Gutenberg 保存按钮的状态。当每个区块实例在首次保存时都能保留默认值,并且保存后保存按钮保持禁用状态时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
ACF V3 blocks with autoInlineEditing: true do not commit field default_value to block attrs on first save, unless the user explicitly interacts with an ACF field before saving. The ACF 6.6.2 changelog states this was fixed ("V3 Blocks now save default field values even if the block wasn't interacted with before saving"), but the fix does not apply when only InnerBlocks are edited.
Additionally, after saving a page containing such a block for the first time, the Gutenberg save button re-activates — suggesting ACF is modifying post_content server-side after the save, causing the editor to detect a content mismatch. When two or more instances of the same block are on the same page, only the last one has defaults correctly applied after the second save.
To Reproduce
Register a V3 ACF block with autoInlineEditing: true containing a select field with a default_value and an InnerBlocks area.
Insert the block on a page. The ACF field shows the default value in the editor sidebar (client-side only — expected).
Edit one of the block's InnerBlocks (e.g. type in the paragraph) or do not edit anything at all. Do not touch the ACF select field.
Click Save.
Reload the page in the editor.
Inspect the block — the ACF field is empty in the DB; default_value was not committed.
Expected behavior
The default_value for each field should be committed to block attrs on the first save, consistent with the fix described in the 6.6.2 changelog. The save button should remain disabled after saving with no server-side content mismatch.
Code
block.json:
{
"name": "acf/my-block",
"title": "My Block",
"acf": {
"blockVersion": 3,
"autoInlineEditing": true,
"usePostMeta": false,
"renderTemplate": "my-block.php"
},
"apiVersion": 3
}
my-block.php:
<?php
$layout = get_field( 'layout' ) ?: 'left';
?>
<div class="my-block" data-layout="<?php echo esc_attr( $layout ); ?>">
<InnerBlocks />
</div>
Field group JSON: (drag and drop the exported field group containing the layout select field with default_value: "left", allow_null: 0, assigned to acf/my-block)
Version Information:
WordPress Version: 7.0
PHP Version: 8.5.6
ACF Version: ACF PRO 6.8.1
Browser: Firefox 151.0.1
Additional context
Confirmed on a clean WordPress install with no plugins except ACF PRO 6.8.1. Custom theme hooks were ruled out by testing on a bare theme.
The save button re-activation suggests ACF's server-side processing modifies the serialized block comment after save, causing Gutenberg to detect a mismatch between what the editor sent and what the server returned.
The bug appears specific to autoInlineEditing: true — worth verifying whether the 6.6.2 fix only covers blocks without inline editing.
- 主要语言
- PHP
- 星标
- 948
- 派生
- 198
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
AdvancedCustomFields/acf 的其他 Issue
-
PHP 8.5: "Using null as an array offset" deprecation in ACF_Data::is() when rendering a block with empty data (local-meta.php is_request)可能已有人在做 @faisalahammad 于 11 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 68/100
AdvancedCustomFields/acf#1044 ·
-
is_preview was called incorrectly notice on every early get_field() since 6.8.10 (acf_revisions::acf_validate_post_id)可能已有人在做 @faisalahammad 于 11 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
AdvancedCustomFields/acf#1041 · 1 条评论 ·
-
True / False ACF control bug on RTL layouts可能已有人在做 @elicohenator 于 33 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 86/100
AdvancedCustomFields/acf#1038 ·
-
难度 2/5 1-3 小时 新手友好度 78/100
AdvancedCustomFields/acf#1034 · 3 条评论 ·
-
Bug: class-acf-field-icon_picker.php calls wp_get_attachment_image_url() with string Dashicon slug, causing fatal TypeError on PHP 8+可能已有人在做 @antwonw 于 45 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 86/100
AdvancedCustomFields/acf#1032 · 1 条评论 ·
查看 AdvancedCustomFields/acf 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
Automattic/blocks-engine#3369 ·
维护者通常 1 天内回复
-
0. Needs triage 35-feedback bug
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
product / auth product / databases product / functions product / messaging product / storage product / vcs
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
good first issue ux
难度 1/5 1 小时以内 新手友好度 89/100
alleyinteractive/wp-curate#498 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复