Weird behaviour with iframe and 'beforeunload' event

Issue Description:

Context

  • We have an iframe in our app to serve some information from our website
  • In order to have navigation UI elements and loading indicators in the app itself, we use window.postMessage() to faciliate communication between the iframe and the app
  • The page in the iframe sends a message to the app when the page first loads, and when the beforeunload event fires on the page

Issue

  • When a link in the app not in the iframe is clicked it somehow causes the beforeunload even to fire in the iframe which erroneously causes the loading indicator to show and block interaction with the iframe

Steps to reproduce:

  1. Open the app
  2. Go through onboarding experience, if first launch
  3. Let the iframe in the right side of the app finish loading
  4. Click the “How do I get my sharecode?” link in the left side
  5. Loading indicator should show up over the iframe

Impact for my app: [low, mid, high, show-stopper]

Do you currently have a workaround?

  • If you switch tabs to reset the iframe, then the loading indicator can disappear
  • Otherwise there’s no way to actually avoid the issue

OPK file and video has been linked privately on Slack.

@andrew-gamurs Hi. I’m able to reproduce it.
I can see that when the beforeunload is triggered from the external link, it does not contain the source. Maybe it’s a way to distinguish between the actions and act differently?

@eransharv I have noticed that but it only happens in some cases with no known reason as to why it does or doesn’t have the source attribute so we can’t rely on that as a differentiator.

@andrew-gamurs ok. I will check for other possible solutions and let you know.
Thanks.

@andrew-gamurs I escalated it to our R&D backlog. We will keep you updated.

Thanks.

@eransharv hi! any updates on this issue? thanks