Shemesh / angular-popout-window

Angular Popout Child Window
MIT License
11 stars 6 forks source link

Persistent stylebinding #9

Closed GIimmer closed 2 years ago

GIimmer commented 2 years ago

This PR should help show an issue that I faced using this code in production, as well as a fix I wrote for the issue.

The problem: After the child component is popped out, any further style-changes to the parent window are not applied to the child window. This became an issue because Angular loads component styling into tags only once they are shown, and when it does - they are only loaded to the parent window. So if a child doesn't exist on the DOM (e.g. due to *ngIf) before it's popped out, once it is shown, the styles will not propagate to the child window.

The first commit is the fix, the second commit adds example code which should illustrate the issue, which may need to be removed.

The fix is accomplished by observing style mutations to the tag, and copying them over to the child window.

*I also added a 'closed' emitter; I feel this can be useful in a few ways - including in my case, where I had to run change detection on close, which wasn't triggered by closing the child window.

Shemesh commented 2 years ago

merged & published

GIimmer commented 2 years ago

Brilliant, appreciated