Skip to content

Conversation

@leekelleher
Copy link
Member

Description

Fixes #19443 and #19471.

PR #9046 added the concept of preview sessions for v8.10. This enabled a way to track how many browser tabs/windows were actively viewing in preview mode. When a browser tab/window was closed, the number would decrease, when zero, the preview mode would exit.

Since implementing this feature for v14+ and investigating subsequent bug reports, we found that the original implementation had a design flaw, in that the initial number of sessions created was doubled due to the "UmbPreviewSessionAmount" localStorage value being set in both the backoffice preview app ("preview.controller.js‎") and the frontend website's preview toolbar ("websitepreview.js").

(Side-note: The backoffice preview app would attempt to hide the frontend preview toolbar, #umbracoPreviewBadge, but this was after the scripts had already executed).

This meant that when a browser tab/window was closed, the session number would decrease, but it wouldn't hit zero (and wouldn't exit the preview mode). Browser reloads would decrement the session amount, then increment again on load, (e.g. if the amount were zero, then the preview mode would be exited, as described in #19443).

Upon review of how to resolve this for v16+, we came to the conclusion that exiting preview mode should be a deliberate action by the user. To that, we have removed the concept of preview sessions from the preview-app.

It is worth noting that the Preview Auto-Exit/prompt feature (e.g. the "UMB-WEBSITE-PREVIEW-ACCEPT" timeout cookie) has not been ported over to v14+ yet.

How to test?

Try to reproduce the bugs raised in #19443 and #19471. e.g. repeatedly hitting reload whilst in preview mode.

Fixes #19443 and #19471.

The implementation of exiting sessions was a design flawed.
The v13 feature worked due to an implementation bug.

Exiting preview mode should be a deliberate action by the user.
@Copilot Copilot AI review requested due to automatic review settings October 20, 2025 10:34
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 removes the preview sessions feature from Umbraco's preview functionality to resolve issues where preview mode wouldn't properly exit due to session counting problems. The original implementation had a design flaw where sessions were being double-counted, preventing proper exit behavior.

  • Removes session tracking logic including localStorage session management
  • Simplifies preview exit to be a deliberate user action rather than automatic
  • Eliminates visibility change handlers and beforeunload event listeners

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
preview.element.ts Removes lifecycle callbacks for session management and visibility tracking
preview.context.ts Eliminates session counting methods and simplifies exit preview logic
preview-exit.element.ts Updates exit button to call simplified exitPreview method

# Conflicts:
#	src/Umbraco.Web.UI.Client/src/apps/preview/apps/preview-exit.element.ts
#	src/Umbraco.Web.UI.Client/src/apps/preview/preview.context.ts
@iOvergaard iOvergaard merged commit 9cc2df7 into v17/dev Oct 23, 2025
26 of 27 checks passed
@iOvergaard iOvergaard deleted the v17/feature/preview-session-removal branch October 23, 2025 09:47
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.

2 participants