-
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
Prevent Pre-Publish Panel from Displaying Incorrect Information After Navigating away #67010
Prevent Pre-Publish Panel from Displaying Incorrect Information After Navigating away #67010
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @sarthaknagoshe2002! In case you missed it, we'd love to have you join us in our Slack community. If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information. |
( prevProps.isPublished && | ||
! this.props.isSaving && | ||
this.props.isDirty ) || | ||
! this.props.postlink |
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 a better check would be to see if the currentPostId changed: this.props.currentPostId !== prevProps.currentPostId
, where currentPostId
is select(editorStore).getCurrentPostId()
.
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.
Hey @ntsekouras, thanks for suggesting a better approach!
I have implemented the suggested changes, please have a look.
Thanks 🙌🏻
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.
Thank you! Let's use getCurrentPostId
selector though instead of getEditedPostAttribute( 'id' )
and name the prop currentPostId
for clarity.
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.
@ntsekouras I have implemented the changes!
Also, can you highlight on why using getCurrentPostId
is a better approach?
Thanks 🙌🏻
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.
Sure. Since we only want the id
, getCurrentPostId
returns that directly from the state whereas getEditedPostAttribute
is a doing more and we don't need to fetch all the edits etc..
…f getEditedPostAttribute
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.
LGTM, thank you! Mobile tests have an issue in general now, so let's see if they are resolved soon and try to rebase and land.
Fixes: #64913
What?
This PR addresses a bug highlighted in #64913 where the pre-publish panel displays incorrect or broken information when switching to edit a template part. Specifically, if you open the pre-publish checks and immediately switch to edit a template part, the panel continues to show details about the template part, instead of closing or updating appropriately.
Why?
This fix improves the user experience by preventing confusion caused by incorrect information in the pre-publish panel. It ensures the behavior aligns with expectations, where the pre-publish is closed when navigating away.
How?
The issue is resolved by ensuring that when the user navigates away from editing the page, the pre-publish panel is closed. This change ensures that the publish flow is not interrupted and the pre-publish checks are only shown for the current page or post, not the template part.
Testing Instructions
publish
to open the pre-publish panelScreenshots or screencast
pre-publish.panel.bug.mov