fix(VP-556): replace deprecated unload event with pagehide in page traversal#599
Open
kirtesh-cstk wants to merge 6 commits into
Open
fix(VP-556): replace deprecated unload event with pagehide in page traversal#599kirtesh-cstk wants to merge 6 commits into
kirtesh-cstk wants to merge 6 commits into
Conversation
release: 4.4.2
…aversal The unload event is deprecated in modern browsers (suppressed since Chrome 115+ for BFCache compatibility) and was used to notify the parent frame when a user navigates to a new page in the live preview iframe. Replaced with the pagehide event, which is the browser-recommended drop-in replacement — it fires in the same scenarios without blocking BFCache. Also deleted src/utils/handlePageTraversal.ts which was dead code (not imported anywhere) but also contained a deprecated unload listener. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
🔒 Security Scan Results
⏱️ SLA Breach Summary
✅ BUILD PASSED - All security checks passed |
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||
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.
Summary
window.addEventListener("unload", ...)withwindow.addEventListener("pagehide", ...)in src/livePreview/onPageTraversal.tssrc/utils/handlePageTraversal.ts— this file was dead code (not imported anywhere) but also contained a deprecatedunloadlistenerpagehideevent is the browser-recommended drop-in replacement forunload; it fires in the same navigation scenarios without blocking the Back-Forward Cache (BFCache)Jira: VP-556
Why this change
The
unloadevent has been deprecated since Chrome 115+ as part of BFCache improvements. Browsers suppress it silently in many scenarios, making it unreliable.pagehideis the standardized replacement with identical semantics for page navigation tracking.The affected code notifies the parent Contentstack window (via
livePreviewPostMessage.send) when a user navigates to a new page inside the live preview iframe, so the parent can sync its own navigation.Impact areas to verify
Please test the following areas end-to-end to confirm no regression:
url-changepostMessage event from this SDK; if so, confirm navigation between pages in the preview still works correctly after this changeNotes
advanced-post-messagetransport layer is unchanged — only the trigger event (unload→pagehide) is swapped{ targetURL }) or event type ("url-change")