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

Leave site? Alert too aggressive when EditFlow and Custom Statuses is enabled. #690

Open
jomurgel opened this issue Nov 30, 2022 · 0 comments

Comments

@jomurgel
Copy link

Expected/Desired Behavior

Fill with either one:

The value of getPostEdits (wp.data.select('core/editor').getPostEdits()) would be empty until post save or unless the EditFlow status dropdown has changed.

Actual Behavior

After creating a new post, because of how the code changing the custom status

subscribe( function () {
const postId = select( 'core/editor' ).getCurrentPostId();
if ( ! postId ) {
// Post isn't ready yet so don't do anything.
return;
}
// For new posts, we need to force the default custom status.
const isCleanNewPost = select( 'core/editor' ).isCleanNewPost();
if ( isCleanNewPost ) {
dispatch( 'core/editor' ).editPost( {
status: ef_default_custom_status
} );
}
// If the save button exists, let's update the text if needed.
maybeUpdateButtonText( document.querySelector( '.editor-post-save-draft' ) );
// The post is being saved, so we need to set up an observer to update the button text when it's back.
if ( buttonTextObserver === null && window.MutationObserver && select( 'core/editor' ).isSavingPost() ) {
buttonTextObserver = createButtonObserver( document.querySelector( '.edit-post-header__settings' ) );
}
} );
is subscribed we immediately have a post edit (wp.data.select( 'core' ).getEntityRecordNonTransientEdits('postType', POST_TYPE, POST_ID )) which means that even if no changes were made when trying to leave the post or close the tab we are met with the "Leave site? Changes you made may not be saved." which is very confusing for editors.

image

Steps to Reproduce the Problem

  1. Create post. Do nothing.
  2. Attempt to close the tab or leave the page.
  3. Confirm that the "Leave site?" alert is present.

(Optional) Additional notes

The solution may be to, if nothing has changed in the dropdown, add the default in PHP on post save (rest_pre_insert_${post_type} or on the save_post hook).

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

No branches or pull requests

1 participant