Skip to content

Commit

Permalink
Editor: Reset Post Edits when switching posts in the post editor
Browse files Browse the repository at this point in the history
If we create a new post, switch to a draft from the sidebar without saving
and coming back to /post/new again, some initial post edits were kept instead of having a fresh new post
  • Loading branch information
youknowriad committed Dec 20, 2016
1 parent 46c2a23 commit 107957e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions client/post-editor/post-editor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@ export const PostEditor = React.createClass( {

componentWillReceiveProps: function( nextProps ) {
const { siteId, postId } = this.props;

// When switching posts, reset post edits for the post we're leaving
if ( nextProps.postId !== postId ) {
this.props.resetPostEdits( siteId, postId );
}

if ( nextProps.siteId === siteId && nextProps.postId !== postId ) {
// make sure the history entry has the post ID in it, but don't dispatch
page.replace( nextProps.editPath, null, false, false );
Expand Down

0 comments on commit 107957e

Please sign in to comment.