Skip to content
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

Autosave continues to trigger for published posts when no changes applied #12318

Closed
gziolo opened this issue Nov 26, 2018 · 3 comments · Fixed by #12624
Closed

Autosave continues to trigger for published posts when no changes applied #12318

gziolo opened this issue Nov 26, 2018 · 3 comments · Fixed by #12624
Assignees
Labels
[Feature] Writing Flow Block selection, navigation, splitting, merging, deletion... [Type] Bug An existing feature does not function as intended

Comments

@gziolo
Copy link
Member

gziolo commented Nov 26, 2018

Describe the bug

I discovered that autosave triggers even when there were no changes applied only for the published post. It works perfectly fine for drafts.

To Reproduce
Steps to reproduce the behavior:

  1. Create a post (it isn't related to demo post only), write some content and publish it.
  2. Reopen your published post.
  3. Open network tab in your browser's developer tools.
  4. Change something in one of the blocks.
  5. Observer autosave being triggered after your changes were autosaved.

Expected behavior
Autosave is triggered only once after content in the published post has changed.

Screenshots
autosave-published-post

Desktop (please complete the following information):

  • OS: macOS Mojave
  • Browser: Chrome
  • Version: 70
@gziolo gziolo added [Feature] Writing Flow Block selection, navigation, splitting, merging, deletion... [Type] Bug An existing feature does not function as intended labels Nov 26, 2018
@aduth
Copy link
Member

aduth commented Nov 26, 2018

It's technically expected that the post remains "dirty" after an autosave occurs, because it is not a full save for a published post. So while we expect the user should be prompted about unsaved changes (which occurs in the classic editor as well), the autosaves themselves should discontinue after the first.

@aduth aduth self-assigned this Nov 26, 2018
@aduth
Copy link
Member

aduth commented Nov 26, 2018

This may require some new state to distinguish a post which is dirty but for which a user has not made changes since the last save, to be used in considering whether the AutosaveMonitor component should schedule an autosave. In other words, a post may be dirty (prompt on navigate) but not a candidate for autosave.

Reducer pseudo-code:

function hasUnsavedUserEdits( state = false, action ) {
	switch ( action.type ) {
		case 'REQUEST_POST_UPDATE_SUCCESS':
			return false;

		case 'EDIT_POST':
		/* ... all other user edit actions as `case` */
			return true;
	}

	return state;
}

There's some conceptual overlap with the getReferenceByDistinctEdits selector, and it's not necessarily safe to assume that some actions are in-fact user-initiated, so there might be some alternative I'm overlooking here.

@aduth
Copy link
Member

aduth commented Dec 5, 2018

Pull request at #12624

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Writing Flow Block selection, navigation, splitting, merging, deletion... [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants