From 5d24debbeb3251b1b612634925bf6c0f13efcbab Mon Sep 17 00:00:00 2001 From: Sarthak Nagoshe <83178197+sarthaknagoshe2002@users.noreply.github.com> Date: Tue, 19 Nov 2024 14:55:13 +0530 Subject: [PATCH] Prevent Pre-Publish Panel from Displaying Incorrect Information After Navigating away (#67010) Co-authored-by: sarthaknagoshe2002 Co-authored-by: ntsekouras Co-authored-by: jameskoster --- .../editor/src/components/post-publish-panel/index.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/editor/src/components/post-publish-panel/index.js b/packages/editor/src/components/post-publish-panel/index.js index 6a2d393e20c4ba..1fd36f9f69d7a2 100644 --- a/packages/editor/src/components/post-publish-panel/index.js +++ b/packages/editor/src/components/post-publish-panel/index.js @@ -47,9 +47,10 @@ export class PostPublishPanel extends Component { // Automatically collapse the publish sidebar when a post // is published and the user makes an edit. if ( - prevProps.isPublished && - ! this.props.isSaving && - this.props.isDirty + ( prevProps.isPublished && + ! this.props.isSaving && + this.props.isDirty ) || + this.props.currentPostId !== prevProps.currentPostId ) { this.props.onClose(); } @@ -75,6 +76,7 @@ export class PostPublishPanel extends Component { onTogglePublishSidebar, PostPublishExtension, PrePublishExtension, + currentPostId, ...additionalProps } = this.props; const { @@ -154,6 +156,7 @@ export default compose( [ const { getPostType } = select( coreStore ); const { getCurrentPost, + getCurrentPostId, getEditedPostAttribute, isCurrentPostPublished, isCurrentPostScheduled, @@ -177,6 +180,7 @@ export default compose( [ isSaving: isSavingPost() && ! isAutosavingPost(), isSavingNonPostEntityChanges: isSavingNonPostEntityChanges(), isScheduled: isCurrentPostScheduled(), + currentPostId: getCurrentPostId(), }; } ), withDispatch( ( dispatch, { isPublishSidebarEnabled } ) => {