Repository navigation
feat: apply post type templates to new posts - #794
Merged
dcalhoun merged 8 commits intoOct 30, 2026
Merged
Conversation
XCFramework BuildThis PR's XCFramework is available for testing. Add the following to your .package(url: "https://github.com/wordpress-mobile/GutenbergKit", branch: "pr-build/794")Built from a4f76ca |
dcalhoun
force-pushed
the
feat/new-post-template-parity
branch
2 times, most recently
from
October 22, 2026 14:19
5da948b to
efee7c1
Compare
This was referenced Oct 22, 2026
dcalhoun
force-pushed
the
feat/new-post-template-parity
branch
from
October 23, 2026 16:17
c9a8cc4 to
bebbccd
Compare
dcalhoun
marked this pull request as ready for review
October 23, 2026 16:31
crazytonyli
requested changes
Oct 28, 2026
crazytonyli
requested changes
Oct 30, 2026
crazytonyli
approved these changes
Oct 30, 2026
WP Admin seeds new posts as auto-drafts, which core relies on to treat a post as new, e.g. `isEditedPostNew()`. Posts without a server ID were seeded with the host's status, usually `draft`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Core applies a post type's block template to new posts, but GBK never passed it to `setupEditor`. Load the post type before rendering and pass its template for new posts without content: unlike WP Admin's auto-drafts, a new post can hold a local draft, which core would replace. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The gbk_templated slug showed as "Gbk_Templated" in the demo apps, and the template's heading text looked like a placeholder beside the paragraph's real placeholder. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YNDBX7RNXn3NsfDuV1PkNV
Core blanks the title of auto-drafts and applies the post type's template to them, so seeding every post without a server ID as one erased local drafts' titles, re-applied deleted templates, and focused the title on reopen. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YNDBX7RNXn3NsfDuV1PkNV
The host compared the editor's content with what it sent, so a new post's template looked like an edit, and hosts prompted to save or uploaded posts the user never touched. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YNDBX7RNXn3NsfDuV1PkNV
Hosts may not preload the post type, such as WordPress-Android for pages, so every other post's first render waited on a network request for a template it never uses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YNDBX7RNXn3NsfDuV1PkNV
WP Admin adds the post type's template and template_lock to the editor settings, so a locked template's blocks can't be removed, moved, or added to. GBK applied the template without the lock. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YNDBX7RNXn3NsfDuV1PkNV
The comment implied only GBK's seeded auto-drafts reach this check, but a status the host sends passes through unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YNDBX7RNXn3NsfDuV1PkNV
dcalhoun
force-pushed
the
feat/new-post-template-parity
branch
from
October 30, 2026 11:12
1fabd04 to
a4f76ca
Compare
Member
Author
|
Rebased to resolve conflicts for the stacked PRs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
Apply post type templates to new posts.
Why?
Close CMM-2551. Align with core's editor behavior.
How?
auto-draftstatus so thatisEditedPostNew()returns trueTesting Instructions
Run
make wp-env-startandmake serve-dev, then open the demo app on iOS and Android and select the local WordPress site. The site registers a Templated Post post type with a block template. If you prepared the editor for this site before, tap Clear Preload Cache first, as the demo app caches the post type..setTitle("Trip notes")toapplyDemoAppDefaultsinios/Demo-iOS/Sources/Views/SitePreparationView.swift. On Android, change.setTitle("")to.setTitle("Trip notes")inSitePreparationViewModel.kt. Select the templated post type and tap Start. Verify that the title reads "Trip notes" and the template isn't applied. Revert the edit.chrome://inspecton Android) attached to the editor, runeditor.getTitleAndContent()in the console. Verify that it returnschanged: false. Type a character, run it again, and verify that it returnschanged: true.'template_lock' => 'all',toregister_post_typeinwp-env/mu-plugins/gutenbergkit-templated-post-type.php, then tap Clear Preload Cache. Select the templated post type and tap Start. Verify that you can type in the template's blocks but can't remove or move them, and can't add blocks. Revert the edit.Tapping into the template's paragraph may hit a caret bug fixed separately in #821.
Accessibility Testing Instructions
N/A, no navigation changes.
Screenshots or screencast
N/A, no visual changes.
AI-generated details
Phase 1b of the CMM-2024 editor-driven saving plan: new-post parity with WP Admin.
auto-draftseed: a post without a server ID (-1) is seeded asauto-draftonly when its title and content are empty, soisEditedPostNew()is true. A local draft keeps the host's status, since core applies the template to auto-drafts, and core-data blanks their titles, which WP Admin restores through initial edits but GBK doesn't. The status stays local: no bridge message sends it to hosts, and writes are blocked.setupEditor. Other posts render without waiting for it.templateandtemplate_lockare added to the editor settings for every post of the type, so locked templates are enforced.getTitleAndContent()compares against the content after setup, so an untouched new post with a template reportschanged: false, and hosts don't prompt to save or upload it.templated_postpost type with a template to wp-env for E2E.Behavior change to note: core's
PostTitlefocuses the title on a clean new post, which matches the hosts' own rule of focusing only empty posts. On iOS, the WebView doesn't show the keyboard for programmatic focus. Android should be checked.Testing
getPost()status for empty posts and local drafts, post type loading for new posts only, the template lock settings, and the host change baseline.new-post-template.spec.js): the template applies to an empty new post, an untouched template isn't reported as a change, the lock reaches the block editor, and a new post with a title or content keeps it.editor-content-changed.spec.js, which is flaky under 7 parallel workers against a slow wp-env (it also fails without these changes).Core behavior to note: after the template applies, Undo is enabled, but the post isn't dirty. Core's
setupEditorapplies templates viaresetEditorBlockswithout an undo level, yeteditPoststill records one. WP Admin callssetupEditorwith the same arguments, so it should behave the same way, though I haven't verified that in WP Admin.🤖 Generated with Claude Code