-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Closed
Labels
FrameworkIssues related to broader framework topics, especially as it relates to javascriptIssues related to broader framework topics, especially as it relates to javascriptREST API InteractionRelated to REST APIRelated to REST API[Type] TaskIssues or PRs that have been broken down into an individual action to takeIssues or PRs that have been broken down into an individual action to take
Milestone
Description
Related: #7122 (comment)
When an autosave occurs for an auto-draft or draft post authored by the same user, the server treats it as a regular save:
gutenberg/lib/class-wp-rest-autosaves-controller.php
Lines 182 to 185 in 7141ce6
if ( ( 'draft' === $post->post_status || 'auto-draft' === $post->post_status ) && $post->post_author == $user_id ) { | |
// Draft posts for the same author: autosaving updates the post and does not create a revision. | |
// Convert the post object to an array and add slashes, wp_update_post expects escaped array. | |
$autosave_id = wp_update_post( wp_slash( (array) $prepared_post ), true ); |
This should also be respected in the client, meaning:
- There should be no prompts for unsaved changes after this occurs
- The post's "current" values, i.e.
state.currentPost
, should reflect anything included in the autosave request
A couple possible implementations may include:
- Testing as a condition of the save effect to consider
isAutosave
asfalse
when the autosave is draft for current user - Handling as a case in the
currentPost
reducer - Dispatch
resetPost
after autosave completes successfully, when autosave is draft for current user
Metadata
Metadata
Assignees
Labels
FrameworkIssues related to broader framework topics, especially as it relates to javascriptIssues related to broader framework topics, especially as it relates to javascriptREST API InteractionRelated to REST APIRelated to REST API[Type] TaskIssues or PRs that have been broken down into an individual action to takeIssues or PRs that have been broken down into an individual action to take