-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Conversation
westonruter
commented
Jul 8, 2017
Closes #1234. |
editor/effects.js
Outdated
type: 'TRASH_POST_SUCCESS', | ||
} ); | ||
}, | ||
( err ) => { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 ) => { |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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
.
63852a3
to
11dcf8b
Compare
Rebased. Former head 63852a3. |
post_type: postType, | ||
ids: postId, | ||
|
||
// Delay redirect to ensure store has been updated with the successful trash. |
There was a problem hiding this comment.
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.