Skip to content
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

Fix draft previews #37952

Merged
merged 6 commits into from
Jan 14, 2022
Merged

Fix draft previews #37952

merged 6 commits into from
Jan 14, 2022

Conversation

jorgecontreras
Copy link
Contributor

Description

Fixes #33616: Draft post not previewable if the draft was previously published.

When the post gets published, an autosave record is generated. Then, if the post is switched to Draft, the generated autosave record becomes stale. Subsequent edits to the post will reflect in the parent record, but not in the autosave record. This condition causes the preview to display the outdated content from the autosave record, which is not up to date with more recent edits. To solve this, the status of the post will be checked during preview link creation and if it's a draft, the autosave record will be ignored.

How has this been tested?

  1. Open the edit page for a brand new post
  2. Add a title and body and hit preview in a new tab
  3. Notice the preview works great
  4. Publish the post
  5. Update the title and body and preview a couple times
  6. Notice preview still works great
  7. Switch the post to a draft
  8. Update the title and content and hit preview
  9. Confirmed that the title and body in the preview match the content from the Editor.
  10. Published the article again and confirmed that the preview still works great.

Screenshots

Types of changes

Bug fix

Checklist:

Jorge Contreras added 5 commits November 11, 2021 13:26
- Fixes issue with draft post not previwable if the draft was previously published.
- During preview link creation, check if current post is in draft status.
- Add end to end test for issue WordPress#33616: Draft post not previewable if the draft was previously published.
- Include a link to the issue that the test validates.
- Use aria-label instead of css class as a selector for Title field.
- Update test title to be more descriptive about the case under test.
@github-actions
Copy link

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @jorgecontreras! In case you missed it, we'd love to have you join us in our Slack community, where we hold regularly weekly meetings open to anyone to coordinate with each other.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Jan 13, 2022
@talldan talldan added [Feature] History History, undo, redo, revisions, autosave. [Type] Bug An existing feature does not function as intended [Feature] Saving Related to saving functionality labels Jan 14, 2022
Copy link
Contributor

@talldan talldan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was previously reviewed on a fork where the PR was accidentally created (Automattic#1), so for anyone looking for more background worth reading that.

Thanks @jorgecontreras for your work here. Also props to @getdave for reviewing that original PR.

@talldan talldan merged commit 500e176 into WordPress:trunk Jan 14, 2022
@talldan talldan changed the title Fix/preview draft Fix draft previews Jan 14, 2022
@github-actions github-actions bot added this to the Gutenberg 12.5 milestone Jan 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] History History, undo, redo, revisions, autosave. [Feature] Saving Related to saving functionality First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Draft posts are not previewable if the draft was previously published
2 participants