Skip to content

Silent refresh causes unnecessary change detect #785

Open
@jonyeezs

Description

@jonyeezs

Describe the bug
When you have other parts of the application having iframes that are sending messages back to the parent window, silent refresh's event listener on message is causing angular to trigger its change detection.

Stackblitz example
I can help setup if someone could point me to a seed stackblitz

To Reproduce
Steps to reproduce the behavior:

  1. Setup silent refresh
  2. Add something triggering window message event
  3. add a ngDoCheck to any component or directive with a console.log
  4. watch it light up.

Expected behavior
Should not have unnecessary change detect due to using silent refresh

Desktop (please complete the following information):

  • OS: Windows
  • Browser Chrome
  • Version ^5.0.2

Additional context
I reckon this should fix it; but then again I'm not sure if there's any where else down the stream you'd need to run inside angular again.

this.ngZone.runOutsideAngular(() => {
    window.addEventListener('message', this.silentRefreshPostMessageEventListener);
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugFor tagging faulty or unexpected behavior.investigation-neededIndication that the maintainer or involved community members may need to investigate more.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions