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,