From 5bf0487ef5239df9fb9202ca3a8287e4422bad22 Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Tue, 14 May 2019 16:17:29 +0200 Subject: [PATCH] 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`. --- src/cdk-experimental/popover-edit/table-directives.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cdk-experimental/popover-edit/table-directives.ts b/src/cdk-experimental/popover-edit/table-directives.ts index 140bdfb9962..54c0694df9a 100644 --- a/src/cdk-experimental/popover-edit/table-directives.ts +++ b/src/cdk-experimental/popover-edit/table-directives.ts @@ -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)); }