-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Site Editor: Fix empty content when creating a new template #28882
Conversation
@@ -50,7 +50,7 @@ export default function NewTemplateDropdown() { | |||
excerpt: description, | |||
// Slugs need to be strings, so this is for template `404` | |||
slug: slug.toString(), | |||
status: 'draft', | |||
status: 'publish', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is not related to the fix, but it was something I've tried changing when investigating.
Thing is, templates are always created as publish
, so using draft
here would only be confusing.
There are other mentions of draft templates in the Navigation sidebar (e.g. drafts items would have a [Draft]
label prepended to the title.
I haven't cleaned them up for now, as I don't think they'd be as confusing as this.
Size Change: +55 B (0%) Total Size: 1.37 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works as advertised! Good to go 🚢
Description
#28229 surfaced a bug with the new template creation in the Site Editor (accessible from Navigation -> Templates ->
+
button).The new template gets created correctly, added to the Redux state, and saved in the database.
Although, it should also inherit the content from the closest more generic template available (e.g. creating
front-page
would inherithome
if it exists, orindex
otherwise).The new template gets the correct content (it's there in both state and DB), but not in the editor.
Reloading the editor would make it show up; as it would opening the template alone in a Post Editor.
All the various contexts look good to me too.
The only issue I've noticed is that the
addTemplate
action (which internally usessaveEntityRecord
to create the template, andsetTemplate
to switch the editor to the new template) doesn't create a new item in'core'.root.entities.data.postType.wp_template.edits
for the new template, which is what the editor provider uses to populate the editor with blocks.This PR adds an
editEntityRecord
dispatch, adding the new template's parsed content to theedits
.How has this been tested?
+
button, and add a new template.index
template).Types of changes
Bug fix (non-breaking change which fixes an issue)
Checklist: