components: md-overlay-container duplicated with angular-hmr

Bug:

When using Hot Module Reload and provide(OVERLAY_CONTAINER_TOKEN, {useValue: createOverlayContainer()}), each reload duplicates md-overlay-container overlay div

What is the expected behavior?

Only one overlay div

What is the current behavior?

Overlay div duplicated image

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 7
  • Comments: 20 (6 by maintainers)

Most upvoted comments

Please, HMR is reaaaaaaaaaaaaaaaallly necessary feature for us, EVERY DAY!

Dear Material team, Could you make HMR work properly with material 2?

I’m experiencing the same as @borislemke reports. I added HMR to my project and if there’s a dialog open, a ghost overlay-container is added.

More importantly, the dialog loses it’s bind to the styles. If you look at the <head> section of the document, among the injected <styles> tags you can find the specific <style> dedicated to mat-dialog-container . After a save (with hmr enabled), this style tag disappears. Angular “forgets” to inject the style back to the document.

To reproduce:

  1. Enable HMR on a project with Angular Material 2
  2. Set up a Material Dialog and open it
  3. Inspect the mat-dialog-container element
  4. In the inspector, click on the <style>…</style> link to the right of the mat-dialog-container class name - It’ll take you to the <head> section and focus you on the relevant <style> tag
  5. Change anything in your code - a TS, HTML or SCSS of any component, and save
  6. Hot loading occurs without errors
  7. The dialog corrupts as its relevant <style> tag in the head disappears.
  8. More than this is happening, as you can notice that elements in the dialog are not clickable (even when you get to them with the inspector’s help)

I hope someone can get to the bottom of this. As I work on dialogs at the moment, I have to disable HMR as it makes it impossible to save any changes without a manual reload of the page.

Before HMR reload screenshot - 21_12_2017 22_57_42

After HMR reload screenshot - 21_12_2017 22_58_09

Any update on this issue, it’s been over two years and to be honest while the ‘hack solution’ suggested by seabass223 works it’s quite cumbersome and should not be required.

@torabian dude beat it with the completely unrelated self promotion