Editor: Fix autosaves for draft and auto-draft posts#76624
Conversation
|
Size Change: -3 B (0%) Total Size: 8.75 MB
ℹ️ View Unchanged
|
|
Flaky tests detected in b273a76. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/23240614191
|
|
|
||
| const content = select.getEditedPostContent(); | ||
|
|
||
| if ( ! options.isAutosave ) { |
There was a problem hiding this comment.
Has this changed recently, is this a recent regression?
There was a problem hiding this comment.
Also what about the case of non draft posts, it seems in this case the should keep this condition no?
There was a problem hiding this comment.
I think it's a very old regression. I included details in the PR description. The guard was introduced before there was an undoIgnore flag, but we forgot to remove it after.
This has no visible effect on non-draft posts; the only change is that content is replaced with the evaluated string, but it still remains dirty.
|
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org> Co-authored-by: youknowriad <youknowriad@git.wordpress.org> Co-authored-by: ntsekouras <ntsekouras@git.wordpress.org> Co-authored-by: alecgeatches <alecgeatches@git.wordpress.org> Co-authored-by: chriszarate <czarate@git.wordpress.org>
What?
Closes #76143.
PR fixes a bug when post content remained "dirty" (
content: fn()) after autosaving a draft or auto-draft post, which is usually processed as a normal save.Why?
During autosave,
contentwas replaced with the evaluated value, which later prevented cleanup inRECEIVE_ITEMSbecausefastDeepEqual(fn, string)was always false.How?
Remove
! options.isAutosaveguard, which was introduced in #17420, but was no longer needed after #17452.Ideally, we could remove content evaluation from
savePostand let thesaveEntityRecordhandle it, but this would be a breaking change since filters expectedits.contentto be a string.Testing Instructions
window.wp.data.dispatch( 'core/editor' ).autosave().I've added an e2e test that fails on trunk when RTC is disabled.
Testing Instructions for Keyboard
Same.
Use of AI Tools
Used Cluade to run simulations for a couple of fix options I had in mind.