Skip to content

Commit

Permalink
Fix go back context multiple modals (#3406)
Browse files Browse the repository at this point in the history
  • Loading branch information
ndricimrr committed Aug 28, 2023
1 parent d457d3c commit a9de0c7
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions core/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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)) {
Expand Down

0 comments on commit a9de0c7

Please sign in to comment.