-
Notifications
You must be signed in to change notification settings - Fork 6.8k
CdkPortalOutlet hasAttached not called when using attachComponentPortal #8628
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
Labels
P3
An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Comments
crisbeto
added a commit
to crisbeto/material2
that referenced
this issue
Nov 25, 2017
… attached too early Fixes the `hasAttached` method always returning false when the portal was attached using `CdkPortalOutlet.attachComponentPortal` or `CdkPortalOutlet.attachTemplatePortal`. This means that checks like https://github.com/angular/material2/blob/master/src/lib/dialog/dialog-container.ts#L118 always evaluate to false. Fixing `hasAttached` revealed another issue: if a portal outlet is unbound (e.g. `<div cdkPortalOutlet>`) and the consumer attaches something to it on the first CD round, the content will be cleared immediately due to Angular invoking the getter with an empty string. This has been fixed by ignoring strings altogether since the portal outlet can't do anything with them anyway and they don't match the type signature. Fixes angular#8628.
crisbeto
added a commit
to crisbeto/material2
that referenced
this issue
Nov 25, 2017
… attached too early Fixes the `hasAttached` method always returning false when the portal was attached using `CdkPortalOutlet.attachComponentPortal` or `CdkPortalOutlet.attachTemplatePortal`. This means that checks like https://github.com/angular/material2/blob/master/src/lib/dialog/dialog-container.ts#L118 always evaluate to false. Fixing `hasAttached` revealed another issue: if a portal outlet is unbound (e.g. `<div cdkPortalOutlet>`) and the consumer attaches something to it on the before the first CD round, the content will be cleared immediately due to Angular invoking the getter with an empty string. This has been fixed by not clearing any previously-attached portals if the reset value is set before `ngOnInit`. Fixes angular#8628.
crisbeto
added a commit
to crisbeto/material2
that referenced
this issue
Nov 27, 2017
… attached too early Fixes the `hasAttached` method always returning false when the portal was attached using `CdkPortalOutlet.attachComponentPortal` or `CdkPortalOutlet.attachTemplatePortal`. This means that checks like https://github.com/angular/material2/blob/master/src/lib/dialog/dialog-container.ts#L118 always evaluate to false. Fixing `hasAttached` revealed another issue: if a portal outlet is unbound (e.g. `<div cdkPortalOutlet>`) and the consumer attaches something to it on the before the first CD round, the content will be cleared immediately due to Angular invoking the getter with an empty string. This has been fixed by not clearing any previously-attached portals if the reset value is set before `ngOnInit`. Fixes angular#8628.
mmalerba
pushed a commit
that referenced
this issue
Dec 8, 2017
… attached too early (#8642) Fixes the `hasAttached` method always returning false when the portal was attached using `CdkPortalOutlet.attachComponentPortal` or `CdkPortalOutlet.attachTemplatePortal`. This means that checks like https://github.com/angular/material2/blob/master/src/lib/dialog/dialog-container.ts#L118 always evaluate to false. Fixing `hasAttached` revealed another issue: if a portal outlet is unbound (e.g. `<div cdkPortalOutlet>`) and the consumer attaches something to it on the before the first CD round, the content will be cleared immediately due to Angular invoking the getter with an empty string. This has been fixed by not clearing any previously-attached portals if the reset value is set before `ngOnInit`. Fixes #8628.
mmalerba
pushed a commit
that referenced
this issue
Dec 8, 2017
… attached too early (#8642) Fixes the `hasAttached` method always returning false when the portal was attached using `CdkPortalOutlet.attachComponentPortal` or `CdkPortalOutlet.attachTemplatePortal`. This means that checks like https://github.com/angular/material2/blob/master/src/lib/dialog/dialog-container.ts#L118 always evaluate to false. Fixing `hasAttached` revealed another issue: if a portal outlet is unbound (e.g. `<div cdkPortalOutlet>`) and the consumer attaches something to it on the before the first CD round, the content will be cleared immediately due to Angular invoking the getter with an empty string. This has been fixed by not clearing any previously-attached portals if the reset value is set before `ngOnInit`. Fixes #8628.
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
P3
An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Bug, feature request, or proposal:
Bug report
What is the expected behavior?
When I attach a
Component
or aTemplate
to aCdkPortalOutlet
usingattachComponentPortal
orattachTemplatePortal
, I expect thathasAttached
returns true.What is the current behavior?
hasAttached
always returns false, except, when using thecdkPortalOutlet
-input t oset theportal
.What are the steps to reproduce?
Component
, which contains acdkPortalOutlet
.CdkPortalOutlet
-Directive using@ViewChild(CdkPortalOutlet)
.Template
to it, usingattachTemplatePortal
.hasAttached()
which should return false.Which versions of Angular, Material, OS, TypeScript, browsers are affected?
I am using Angular Material+CDK version 5.0.0-rc.1 as awell as Angular version 5.0.3
Is there anything else we should know?
The problem is in portal-directives.ts#L114 and portal-directives.ts#L129, where
this._portal = portal
should probably bethis.portal = portal
, so that the setter is called and updates the_attachedPortal
of the super-class.The text was updated successfully, but these errors were encountered: