From e96e41c5eb9d31be12d4f112a7b38cf316e555e4 Mon Sep 17 00:00:00 2001 From: kapnak <31968506+kapnak@users.noreply.github.com> Date: Mon, 18 Nov 2024 13:04:24 +0100 Subject: [PATCH] Fix #16298 (#16593) --- src/app/components/menu/menu.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/app/components/menu/menu.ts b/src/app/components/menu/menu.ts index 04c7c69d3f8..6079c76fd82 100755 --- a/src/app/components/menu/menu.ts +++ b/src/app/components/menu/menu.ts @@ -724,8 +724,9 @@ export class Menu implements OnDestroy { const documentTarget: any = this.el ? this.el.nativeElement.ownerDocument : 'document'; this.documentClickListener = this.renderer.listen(documentTarget, 'click', (event) => { - const isOutsideContainer = this.containerViewChild?.nativeElement && !this.containerViewChild?.nativeElement.contains(event.target); - const isOutsideTarget = !(this.target && (this.target === event.target || this.target.contains(event.target))); + const eventTarget = event.composed ? event.composedPath()[0] : event.target; + const isOutsideContainer = this.containerViewChild?.nativeElement && !this.containerViewChild?.nativeElement.contains(eventTarget); + const isOutsideTarget = !(this.target && (this.target === eventTarget || this.target.contains(eventTarget))); if (!this.popup && isOutsideContainer && isOutsideTarget) { this.onListBlur(event); }