Skip to content

Post editor: saving after switching to and editing template on new post returns 400 #56842

Open

Description

Description

On new posts with no content, switching to (or creating), editing then saving a template triggers the "empty_content" server error.

POST response from /index.php?rest_route=/wp/v2/posts/246&_locale=user

{
    "code": "empty_content",
    "message": "Content, title, and excerpt are empty.",
    "data": {
        "status": 400
    }
}

The post is 'technically' dirty as the template slug has been updated on switch via editPost, hence the reason it appears in the saved entities list.

Screenshot 2023-12-07 at 11 36 31 am

Alternatives in no particular order of usefulness

  • Allow saving in this instance without content/title/excerpt changes
  • Save only the template and "unmark" the post entity as dirty, maybe turning off template editing mode and returning to the post afterwards
  • Warn the user that the post is empty 🤷🏻

Step-by-step reproduction instructions

  1. Open the post editor
  2. Switch templates using the drop down in the Template panel (right hand side). Creating a new template also triggers the error.
  3. Edit the template
  4. Make a change to the template
  5. Save the post (site and post entities)
  6. Observer the UI error message and network error (400)

What I expected

The template and post (with updated template slug) to save without error.

Screenshots, screen recording, code snippet

Creating a template:

2023-12-07.09.43.36.mp4

Swapping to a template:

2023-12-07.11.37.51.mp4

Environment info

  • WordPress 6.5 alpha
  • Gutenberg trunk @ 17.2

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    [Package] Edit Post/packages/edit-post[Type] BugAn existing feature does not function as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions