Pattern override edits are lost when saving

未关闭
#883 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
48/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
javascript, react, wordpress
领域
frontend, mobile

调研方向

Start by tracing how GutenbergKit initializes the editor and registers block bindings; the issue identifies core/pattern-overrides and registerCoreBlockBindingsSources() as the relevant entry points. Compare this setup with WP Admin's source registration, including the labels and context listed in the issue. Done when overrides are saved into post content and existing overrides display correctly; the issue does not name a test file.

由索引模型根据 Issue 内容生成。

描述

[Type] Bug
Description

Synced patterns can mark some of their content as editable per use ("pattern overrides"). In GutenbergKit, those fields look editable, but the changes never reach the post.

  • Typing into an overridable field shows the new text, but the saved content doesn't include it. When the user reopens the post, the field shows the pattern's original text.
  • Overrides saved elsewhere (e.g. in WP Admin) are kept in the post's content, but the editor displays the pattern's original text instead.

Expected: override edits are saved, and existing overrides are displayed, as in WP Admin.

Step-by-step reproduction instructions
  1. In WP Admin, create a synced pattern containing a paragraph, and enable overrides for that paragraph (Advanced → "Enable overrides").
  2. Insert the pattern into a post in GutenbergKit.
  3. Type into the paragraph.
  4. Save and reopen the post: the typed text is gone.
Screenshots, screen recording, code snippet

After typing " OVERRIDDEN" into the overridable paragraph, getTitleAndContent() returns <!-- wp:block {"ref":N} /-->, with no content attribute. With the sources registered (see below), it returns <!-- wp:block {"ref":N,"content":{"Body":{"content":"Override me OVERRIDDEN"}}} /-->.

Additional AI-generated details
  • Cause: GutenbergKit never registers the editor's block-bindings sources, which include core/pattern-overrides. WP Admin does it in two steps:
    • The server bootstraps each registered source's name, label and usesContext with an inline wp.blocks.registerBlockBindingsSource() call.
    • edit-post then calls registerCoreBlockBindingsSources(), a private API of @wordpress/editor, to add the client handlers.
  • registerBlockBindingsSource silently refuses a source without a label. Calling registerCoreBlockBindingsSources() on its own therefore registers nothing in GutenbergKit, where there's no server bootstrap.
  • What fixed it in a local test (web): register the four core sources first, with their labels and context, then call registerCoreBlockBindingsSources(). Both typing and display then worked. The sources and their contexts:
    • core/pattern-overrides: pattern/overrides
    • core/post-meta and core/post-data: postId, postType
    • core/term-data: termId, taxonomy
  • core/post-meta bindings are probably affected too (untested). Sources registered by plugins would need their labels from the server.
Environment info

GutenbergKit trunk (5f799a1f), @wordpress/editor 16.0.0. Reproduced in the web editor against a local WordPress site (latest release, Gutenberg plugin, Twenty Twenty-Five). The code path is shared with the iOS and Android editors.

Please confirm that you have searched existing issues in the repo.
  • Yes
主要语言
JavaScript
星标
29
派生
6
平均合并
2 天 1 小时
30 天内合并 PR
76

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

wordpress-mobile/GutenbergKit 的其他 Issue

查看 wordpress-mobile/GutenbergKit 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。