From 5463677237bd92e298aeff4b9c1f9450a7f433c7 Mon Sep 17 00:00:00 2001 From: thePR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> Date: Thu, 9 Oct 2025 19:59:00 -0400 Subject: [PATCH] Fix video modal rehydration after back navigation --- js/app.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/js/app.js b/js/app.js index c39c6bf9..80bf9828 100644 --- a/js/app.js +++ b/js/app.js @@ -1313,9 +1313,25 @@ class Application { const existingVideoElement = getVideoElement(); if (existingRoot && existingRoot.isConnected) { - if (ensureVideoElement && !existingVideoElement) { - throw new Error("Video modal video element is not ready."); + if (!existingVideoElement && ensureVideoElement) { + if (typeof this.videoModal.load === "function") { + await this.videoModal.load(); + } + + const rehydratedRoot = getRoot(); + const rehydratedVideoElement = getVideoElement(); + + if (!rehydratedVideoElement) { + throw new Error("Video modal video element is not ready."); + } + + this.modalVideo = rehydratedVideoElement; + return { + root: rehydratedRoot || existingRoot, + videoElement: rehydratedVideoElement, + }; } + if (existingVideoElement) { this.modalVideo = existingVideoElement; }