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: preview mode bugs with preview on unpublished posts #193

Merged
merged 14 commits into from
Jan 3, 2022
Merged

Conversation

ccorda
Copy link
Contributor

@ccorda ccorda commented Jan 1, 2022

closes #192

See #192 for some background on problem, and how I narrowed it down to a preview bug and not a CDN + caching one.

There are 3 issues resolved here:

1: Currently, if you save a theme option headless variable in production, it is ignored (it's only checked on staging). But sometimes we want to test a preview url in prod, like this instance here for debugging.

2: Currently, on an already published page (e.g. post_id = 9, if you make a change and hit preview, you'll be redirected to the revision id, e.g. /96. This will then grab the correction preview revision data. However when you click edit, it takes you to https://bubsnext.wpengine.com/wp-admin/post.php?action=edit&post=96, which is an error as it's not a post id. The URL we want to edit instead is:
https://bubsnext.wpengine.com/wp-admin/revision.php?revision=96

3: If the page status is draft, and you make a revision then go to preview, the correct behavior is redirect the to go to /{revisionID}, e.g. /95. Currently however it sends you to /3, which loads the orginally saved draft, but doesn't grab your changes.

To recreate any of the above, set the theme option for preview URL to https://bubs.patronage.org. To verify fixes, set to https://bubs-next-git-preview-debug-patronage.vercel.app

@vercel
Copy link

vercel bot commented Jan 1, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/patronage/bubs-next/9vgU9sjAdWo8sJhE4k9bNPu1sMgM
✅ Preview: https://bubs-next-git-preview-debug-patronage.vercel.app

@ccorda
Copy link
Contributor Author

ccorda commented Jan 1, 2022

One question I had for @kylehotchkiss @chrisherold -- I setup WORDPRESS_REVISION_URL to match the existing WORDPRESS_EDIT_URL, but I can't find any instance of us actually using that. Can we remove the reference to that assumed ENV, and just rely on import { WORDPRESS_URL } from 'lib/constants';?

some draft posts are previews, but not all.
@ccorda ccorda changed the title Preview debug fix: preview mode bugs with preview on unpublished posts Jan 1, 2022
@kylehotchkiss
Copy link
Member

I'm a fan of using WORDPRESS_URL and building on top of it around the next app. it looks like revision url and edit url are going to be consistent throughout the codebase and our projects so no need to overwrite them with env vars.

Copy link
Member

@kylehotchkiss kylehotchkiss left a comment

Choose a reason for hiding this comment

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

I wasn't able to try out the changes myself (please send a link to live version if you'd like me to check). The draft IDs problem and solution both make sense and the changes here for passing around the revision ID/status better seem like a good solve.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Preview changes not being picked up
2 participants