Skip to content
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

CdkPortalOutlet attachComponentPortal not render portal to outlet when portal have viewContainerRef #17650

Open
keatkeat87 opened this issue Nov 8, 2019 · 1 comment · May be fixed by #17731
Assignees
Labels

Comments

@keatkeat87
Copy link

@keatkeat87 keatkeat87 commented Nov 8, 2019

actually, I m not 100% confirm this is a bug or is by design. because document not very clear for this part.

Reproduction

https://github.com/keatkeat87/ng-mat-portal-outlet-issue
portal outlet

Expected Behavior

the portal should render in outlet not view container.

Actual Behavior

the portal render in view container.

more details:
I check the source code, class CdkPortalOutlet
image
as the comment said that
// If the portal specifies an origin, use that as the logical location of the component
// in the application tree. Otherwise use the location of this PortalOutlet.
if i not wrong, logical location is not equal to render location, so in this part, should have some code to move the element to outlet location.
i think it should work same as DomPortalOutlet
image
in the end, move element to outlet.
another interesting thing is in class CdkPortalOutlet
when we attach a templatePortal, it just ignore the templatePortal viewContainerRef.
image
it work not same as attach a component portal. it really make user confusing.

Environment

  • Angular: 9.0.0 rc1
  • CDK/Material: 9.0.0 rc 0
  • Browser(s): chrome latest
  • Operating System (e.g. Windows, macOS, Ubuntu): windows 10
@crisbeto crisbeto self-assigned this Nov 17, 2019
crisbeto added a commit to crisbeto/material2 that referenced this issue Nov 17, 2019
…s provided

Fixes the contents of the portal not being rendered inside of the `CdkPortalOutlet`  if an alternate `ViewContainerRef` is provided. We have some logic that moves the content into the outlet for `DomPortalOutlet` already, but we probably missed adding it to the directive since it isn't being used in as many places.

Fixes angular#17650.
@crisbeto

This comment has been minimized.

Copy link
Member

@crisbeto crisbeto commented Nov 17, 2019

You're correct, this is defininitely a bug. We probably hadn't noticed it until now because we either don't pass in a different ViewContainerRef or we use the DomPortalOutlet which doesn't have this issue. Should be fixed in #17731.

jelbourn added a commit that referenced this issue Nov 20, 2019
…s provided

Fixes the contents of the portal not being rendered inside of the `CdkPortalOutlet`  if an alternate `ViewContainerRef` is provided. We have some logic that moves the content into the outlet for `DomPortalOutlet` already, but we probably missed adding it to the directive since it isn't being used in as many places.

Fixes #17650.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.