From 599c47edcf7d32118846679fa6e314f2c5e9fc22 Mon Sep 17 00:00:00 2001 From: Laurent Dinclaux Date: Thu, 5 Feb 2026 04:44:37 +1100 Subject: [PATCH] fix(iframe): prevent reload loop when navigating inside RoundCube Add changeFromIframe flag to track when URL changes originate from iframe navigation vs external route changes. This prevents the queryString watcher from triggering unnecessary iframe reloads, eliminating the white flash when clicking inside the embedded RoundCube interface. --- src/RoundCubeWrapper.vue | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/RoundCubeWrapper.vue b/src/RoundCubeWrapper.vue index 7a83e93..de136ba 100644 --- a/src/RoundCubeWrapper.vue +++ b/src/RoundCubeWrapper.vue @@ -116,6 +116,9 @@ const frameWrapper = ref(null) const externalFrame = ref(null) let iFrameBody: undefined | HTMLBodyElement +// Flag to track if URL change originates from iframe navigation (to prevent reload loop) +let changeFromIframe = false + const contentObserver = new MutationObserver((entries) => { logger.info('MUTATION OBSERVED', { entries }) const iFrame = externalFrame.value! @@ -123,6 +126,11 @@ const contentObserver = new MutationObserver((entries) => { }) watch(queryString, (_value) => { + if (changeFromIframe) { + logger.debug('SKIP IFRAME REFRESH (change from iframe)', { request: requestedLocation.value, current: currentLocation.value }) + changeFromIframe = false + return + } if (requestedLocation.value !== currentLocation.value) { logger.debug('TRIGGER IFRAME REFRESH', { request: requestedLocation.value, current: currentLocation.value }) loading.value = true @@ -182,6 +190,11 @@ const emitLoaded = (iFrame: HTMLIFrameElement) => { currentLocation.value = iFrameWindow.location.href const search = iFrameWindow.location.search const query = Object.fromEntries((new URLSearchParams(search)).entries()) + + // Set flag to prevent watch from triggering iframe reload + // when the URL change originates from iframe navigation + changeFromIframe = true + emit('iframe-loaded', { query, iFrame,