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

Add AYS dialog when attempting to leave editor in dirty state #1816

Merged
merged 2 commits into from
Jul 12, 2017

Conversation

westonruter
Copy link
Member

image

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.02%) to 17.795% when pulling 63852a3 on add/before-unload-warning into 4564ee0 on master.

@mtias
Copy link
Member

mtias commented Jul 11, 2017

Closes #1234.

type: 'TRASH_POST_SUCCESS',
} );
},
( err ) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why doing this in this PR?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I was originally going to use it for checking the dirty state, but I went a different direction. I've split this out into #1857.

editor/index.js Outdated
@@ -82,6 +86,15 @@ export function createEditorInstance( id, post ) {

preparePostState( store, post );

const warnDirtyBeforeUnload = ( event ) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this makes more sense here or further down the tree in a component like the one we have for SavedState.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I'm inclined to create a separate component for this, use lifecycle to add the listeners (willMount, willUnmount) and add it to Layout.

@mtias mtias added [Feature] Document Settings Document settings experience [Type] Task Issues or PRs that have been broken down into an individual action to take labels Jul 11, 2017
@westonruter
Copy link
Member Author

Rebased. Former head 63852a3.

post_type: postType,
ids: postId,

// Delay redirect to ensure store has been updated with the successful trash.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing that might be nice to have with the effects is the next function provided to middlewares, so that we could perform effects before or after the original action has been applied.

@mtias mtias merged commit 5ee31ee into master Jul 12, 2017
@mtias mtias deleted the add/before-unload-warning branch July 12, 2017 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Document Settings Document settings experience [Type] Task Issues or PRs that have been broken down into an individual action to take
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants