Skip to content

Issue #18519: cdk overlay container removed fix #18522

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed

Issue #18519: cdk overlay container removed fix #18522

wants to merge 2 commits into from

Conversation

Tanemahuta
Copy link

So, this is my fix. It works quite well.
The problem was:

  • another angular app (e.g. sideloaded) or other JS code has removed the 'cdk-overlay-container'
  • since all was cached (also the OverlayRefs in the components), the container was not re-created/re-appended to the DOM
    My solution sketch:
  • On the OverlayContainer component:
  • additional check if the HTML element for the overlay has a parentNode (= within the DOM)
  • if the container was removed, it will be re-added (and the others will be removed)
  • On the Overlay service:
  • wrap the PortalOutlet adding a call to the OverlayContainer component which calls the getContainer method and ensures that the HTML element is where it is supposed to be.

Et voilà: it works.

Sorry that I did not include a test, but you should get the idea.

- Ensure the overlay container is always appended to the document
- Wrapping the portal outlet ensuring the overlay is being touched
@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added the cla: no PR author must sign Google's Contributor License Agreement: https://opensource.google.com/docs/cla label Feb 17, 2020
@Tanemahuta Tanemahuta changed the title Issue# 18519: cdk overlay container removed fix Issue #18519: cdk overlay container removed fix Feb 17, 2020
@Tanemahuta
Copy link
Author

@googlebot I fixed it.

@crisbeto
Copy link
Member

Have you tested out the issue that you described with the changes from #17006 (released in 9.0.0)? It should prevent the container from being removed unnecessarily.

@devversion
Copy link
Member

@Tanemahuta Thanks for the proposed fix. Very much appreciated.

I'm closing this PR though as it looks the fix from @crisbeto already resolved this. See: https://stackblitz.com/edit/comp-18519?file=src%2Fapp%2Felement%2Felement.module.ts.

@devversion devversion closed this May 26, 2020
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jun 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: no PR author must sign Google's Contributor License Agreement: https://opensource.google.com/docs/cla
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants