diff --git a/src/app/components/contextmenu/contextmenu.ts b/src/app/components/contextmenu/contextmenu.ts index fb91e757e91..244b020b379 100755 --- a/src/app/components/contextmenu/contextmenu.ts +++ b/src/app/components/contextmenu/contextmenu.ts @@ -1182,11 +1182,9 @@ export class ContextMenu implements OnInit, AfterContentInit, OnDestroy { } removeAppendedElements() { - if (this.appendTo) { + if (this.appendTo && this.containerViewChild) { if (this.appendTo === 'body') { - if (this.containerViewChild) { - this.renderer.removeChild(this.document.body, this.containerViewChild.nativeElement); - } + this.renderer.removeChild(this.document.body, this.containerViewChild.nativeElement); } else { DomHandler.removeChild(this.containerViewChild.nativeElement, this.appendTo); }