From a9de0c7179215dd73ceaf5543e8ef7ec93331448 Mon Sep 17 00:00:00 2001 From: Ndricim Rrapi Date: Mon, 28 Aug 2023 16:47:36 +0200 Subject: [PATCH] Fix go back context multiple modals (#3406) --- core/src/App.svelte | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/core/src/App.svelte b/core/src/App.svelte index ae93506899..acdaed5057 100644 --- a/core/src/App.svelte +++ b/core/src/App.svelte @@ -1568,6 +1568,7 @@ if ('luigi.navigation.back' === e.data.msg) { const mfModalTopMostElement = mfModalList[mfModalList.length - 1]; + const mfModalPreviousElement = mfModalList.length > 1 && mfModalList[mfModalList.length - 2]; const _goBackContext = e.data.goBackContext && JSON.parse(e.data.goBackContext); if ( @@ -1577,9 +1578,19 @@ ) ) { closeModal(mfModalList.length - 1, true, _goBackContext); - - config.iframe && - (await sendContextToClient(config, { + let modalConfig = config; + // special case if going back with multiple modals, context should go back to previous modal, not main iframe + if (mfModalPreviousElement && mfModalPreviousElement.modalIframeData && mfModalPreviousElement.modalIframe){ + const topMostModal = mfModalPreviousElement; + const topMostModalData = topMostModal.modalIframeData; + modalConfig = { + pathParams: topMostModalData.pathParams, + context: topMostModalData.context, + iframe: topMostModal.modalIframe + }; + } + modalConfig.iframe && + (await sendContextToClient(modalConfig, { goBackContext: _goBackContext, })); } else if (IframeHelpers.isMessageSource(e, splitViewIframe)) {