I have a react SPA that uses MSAL and Azure AD B2C for authentication. In every page, the user is able to sign in with 2 ways. The first one is with a button on the header that redirects to the B2C sign in page. The second one is with an iframe that embeds the B2C sign in page and provides an embedded sign in experience. It must be noted that this iframe is provided to the user only when certain actions happen.
It must be noted that the sign in flow inside the iframe works as expected, and the parent page is updated automatically when the user signs in inside the iframe. The "allowRedirectInIframe" is set to true and the Azure AD B2C policy has a JourneyFraming that whitelists the domain and allows rendering of the B2C sign in page inside an iframe. Also, the cache location is set to be the local storage.
The problem is that when the iframe is rendered, but the user clicks the button on the header to be redirected to the sign in page, they get the following error:
BrowserAuthError: interaction_in_progress: Interaction is currently in progress. Please ensure that this interaction has been completed before calling an interactive API. For more visit: aka.ms/msaljs/browser-errors.
The reason seems to be that when the iframe is rendered, entries are added in the session storage which indicate that there is an active interaction, and block the parent page from invoking any redirect to the B2C sign in page.
I've managed to overcome it by doing sessionStorage.removeItem('msal.interaction.status'), when the button on the header is clicked, but it's a hacky solution and I would like to ask if there is any legit way to overcome this issue.