Skip to content

Commit

Permalink
Collapse the publish sidebar when making edits to a published post (#…
Browse files Browse the repository at this point in the history
…4978)

* Collapse publish sidebar when further editing a published post.
* Move logic to componentDidUpdate.
  • Loading branch information
mtias authored Feb 15, 2018
1 parent cf1dd36 commit a7478db
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion editor/components/post-publish-panel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ import './style.scss';
import PostPublishButton from '../post-publish-button';
import PostPublishPanelPrepublish from './prepublish';
import PostPublishPanelPostpublish from './postpublish';
import { getCurrentPostType, isCurrentPostPublished, isSavingPost } from '../../store/selectors';
import {
getCurrentPostType,
isCurrentPostPublished,
isSavingPost,
isEditedPostDirty,
} from '../../store/selectors';

class PostPublishPanel extends Component {
constructor() {
Expand All @@ -43,6 +48,14 @@ class PostPublishPanel extends Component {
}
}

componentDidUpdate( prevProps ) {
// Automatically collapse the publish sidebar when a post
// is published and the user makes an edit.
if ( prevProps.isPublished && this.props.isDirty ) {
this.props.onClose();
}
}

onPublish() {
this.setState( { loading: true } );
}
Expand Down Expand Up @@ -85,6 +98,7 @@ const applyConnect = connect(
postType: getCurrentPostType( state ),
isPublished: isCurrentPostPublished( state ),
isSaving: isSavingPost( state ),
isDirty: isEditedPostDirty( state ),
};
},
);
Expand Down

0 comments on commit a7478db

Please sign in to comment.