fix(propover-edit): incorrect template root note retrieved in ivy

Currently the popover-edit hover directive retrieves the root node
of the embedded view for the popover by looking at the next sibling
of the directive host element. This worked fine in view engine where
the inserted view was added after the current host element, but in
Ivy, the embedded view seems to be inserted before the directive
host node (which is a comment node).

The popover directive should not rely on the implementation detail
of the embedded view insertion and rather retrieve the embedded
view root node through the `EmbeddedViewRef`.
This commit is contained in:
Paul Gschwendtner
2019-05-14 16:17:29 +02:00
committed by Jeremy Elbourn
parent e774692ba0
commit 5bf0487ef5
@@ -374,11 +374,11 @@ export class CdkRowHoverContent implements AfterViewInit, OnDestroy {
// Not doing any positioning in CDK version. Material version
// will absolutely position on right edge of cell.
this.viewRef = this.viewContainerRef.createEmbeddedView(this.templateRef, {});
this.initElement(this.elementRef.nativeElement!.nextSibling as HTMLElement);
this.initElement(this.viewRef.rootNodes[0] as HTMLElement);
} else {
this.viewContainerRef.insert(this.viewRef);
}
this.prepareElement(this.elementRef.nativeElement!.nextSibling as HTMLElement);
this.prepareElement(this.viewRef.rootNodes[0] as HTMLElement);
} else if (this.viewRef) {
this.viewContainerRef.detach(this.viewContainerRef.indexOf(this.viewRef));
}