Skip to content

Skip template edit for empty posts in non-transient edits#70706

Open
BugReportOnWeb wants to merge 5 commits intoWordPress:trunkfrom
BugReportOnWeb:fix/template-change-on-empty-post
Open

Skip template edit for empty posts in non-transient edits#70706
BugReportOnWeb wants to merge 5 commits intoWordPress:trunkfrom
BugReportOnWeb:fix/template-change-on-empty-post

Conversation

@BugReportOnWeb
Copy link
Copy Markdown
Contributor

What?

Closes #56842

Prevents the post from appearing dirty when only the template is changed on an otherwise empty post (no title, content, or excerpt).

Why?

Editing or creating a template on an empty post incorrectly causes the post to appear dirty, enabling the save button. Saving then fails because there are no actual changes of substance in the post itself, just the template assignment.

How?

  • Updates getEntityRecordNonTransientEdits to ignore template as a non-transient edit when the post is clean.
  • This mirrors the behavior of swapping templates where no dirty state is expected.
  • Does not affect posts that contain title, content, or excerpt.

Testing Instructions

  1. Create a new post, and leave it empty
  2. From the post sidebar, create or edit a template.
  3. Ensure the post does not show as dirty (save button disabled).
  4. Ensure no errors occur when navigating away or saving/editing the template.
  5. Repeat with a post that contains title/content to confirm the dirty state works as expected in that case.

Screenshots or screencast

Screen.Recording.2025-07-14.at.1.49.33.PM.mov

@BugReportOnWeb BugReportOnWeb changed the title Fix: Avoid marking template change as dirty edit on empty posts Skip template edit for empty posts in non-transient edits Jul 14, 2025
@BugReportOnWeb BugReportOnWeb marked this pull request as ready for review July 14, 2025 10:07
@BugReportOnWeb BugReportOnWeb requested a review from nerrad as a code owner July 14, 2025 10:07
@github-actions
Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: BugReportOnWeb <devasheeshkaul@git.wordpress.org>
Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions
Copy link
Copy Markdown

Warning: Type of PR label mismatch

To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.

  • Type-related labels to choose from: [Type] Automated Testing, [Type] Breaking Change, [Type] Bug, [Type] Build Tooling, [Type] Code Quality, [Type] Copy, [Type] Developer Documentation, [Type] Enhancement, [Type] Experimental, [Type] Feature, [Type] New API, [Type] Task, [Type] Technical Prototype, [Type] Performance, [Type] Project Management, [Type] Regression, [Type] Security, [Type] WP Core Ticket, Backport from WordPress Core, Gutenberg Plugin.
  • Labels found: .

Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task.

1 similar comment
@github-actions
Copy link
Copy Markdown

Warning: Type of PR label mismatch

To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.

  • Type-related labels to choose from: [Type] Automated Testing, [Type] Breaking Change, [Type] Bug, [Type] Build Tooling, [Type] Code Quality, [Type] Copy, [Type] Developer Documentation, [Type] Enhancement, [Type] Experimental, [Type] Feature, [Type] New API, [Type] Task, [Type] Technical Prototype, [Type] Performance, [Type] Project Management, [Type] Regression, [Type] Security, [Type] WP Core Ticket, Backport from WordPress Core, Gutenberg Plugin.
  • Labels found: .

Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task.

@BugReportOnWeb BugReportOnWeb marked this pull request as draft July 14, 2025 10:41
@BugReportOnWeb BugReportOnWeb marked this pull request as ready for review July 14, 2025 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant