Skip to content

Conversation

@leekelleher
Copy link
Member

@leekelleher leekelleher commented Oct 20, 2025

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.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 iOvergaard merged commit d5a2f05 into main Oct 20, 2025
26 of 27 checks passed
@iOvergaard iOvergaard deleted the v16/bugfix/preview-exit-redirect branch October 20, 2025 09:51
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants