Skip to content

Commit

Permalink
Merge pull request #13960 from maruthumj/appendto-contextualmenu
Browse files Browse the repository at this point in the history
Bug fix #13948 - ContextMenu with appendTo="body" doesn't close when destroyed
  • Loading branch information
cetincakiroglu authored Nov 1, 2023
2 parents fe9e52a + d89afc8 commit 8e16720
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/app/components/contextmenu/contextmenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1148,9 +1148,17 @@ export class ContextMenu implements OnInit, AfterContentInit, OnDestroy {
}
}

removeAppendedElements(){
if (this.appendTo) {
if (this.appendTo === 'body') this.renderer.removeChild(this.document.body, this.containerViewChild.nativeElement);
else DomHandler.removeChild(this.containerViewChild.nativeElement, this.appendTo);
}
}

ngOnDestroy() {
this.unbindGlobalListeners();
this.unbindTriggerEventListener();
this.removeAppendedElements();
}
}

Expand Down

1 comment on commit 8e16720

@vercel
Copy link

@vercel vercel bot commented on 8e16720 Nov 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.