Preview: Redirect to published URL on exit#20556
Merged
iOvergaard merged 4 commits intomainfrom Oct 20, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR enhances the preview functionality to redirect users to the published URL when exiting preview mode, instead of the draft preview URL. If the document is published, users are redirected to the live URL; if unpublished, they're redirected to a 404 page.
Key changes:
- Added logic to fetch published URLs from the DocumentService API
- Modified exit preview behavior to use published URLs when available
- Updated UI elements to handle async operations properly
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/Umbraco.Web.UI.Client/src/apps/preview/preview.context.ts | Added #getPublishedUrl() method and updated exitPreview() and openWebsite() to use published URLs |
| src/Umbraco.Web.UI.Client/src/apps/preview/apps/preview-open-website.element.ts | Updated to await the async openWebsite() call |
| src/Umbraco.Web.UI.Client/src/apps/preview/apps/preview-exit.element.ts | Updated to await the async exitPreview() call |
iOvergaard
approved these changes
Oct 20, 2025
leekelleher
added a commit
that referenced
this pull request
Oct 20, 2025
* Preview Exit: Gets the page's published URL on exit for redirect * Preview Open Website: Uses the page's published URL * Tweaked the published URL logic * Code amends based on @copilot's suggestions (cherry picked from commit d5a2f05)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Currently, when a user exits preview mode, they will be redirect to the frontend of the website with the page URL containing the previewed page's GUID/key. This PR updates the logic to use the page's published URL.
How to test?
When viewing a document in preview mode, press the "End" button and notice the destination of the redirected URL in the browser address bar. If the document has a published state, it will redirect to the published URL, if the document is draft/unpublished, then it will redirect to a 404 (not found) page.