From f33a9987b71dd0b6215b7ec12bd58a6f233d2027 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mehmet=20=C3=87etin?= <92744169+mehmetcetin01140@users.noreply.github.com> Date: Tue, 21 May 2024 12:25:31 +0300 Subject: [PATCH] Fixed #15240 - Menubar | The bug where the menuitems don't close when clicking outside the menuitem in mobile mode --- src/app/components/menubar/menubar.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/app/components/menubar/menubar.ts b/src/app/components/menubar/menubar.ts index 29d2d4c9a59..82c07bc4d43 100755 --- a/src/app/components/menubar/menubar.ts +++ b/src/app/components/menubar/menubar.ts @@ -734,6 +734,7 @@ export class Menubar implements AfterContentInit, OnDestroy, OnInit { hide(event?, isFocus?: boolean) { if (this.mobileActive) { + this.mobileActive = false; setTimeout(() => { DomHandler.focus(this.menubutton.nativeElement); }, 0); @@ -1098,8 +1099,8 @@ export class Menubar implements AfterContentInit, OnDestroy, OnInit { const isOutsideContainer = this.rootmenu.el.nativeElement !== event.target && !this.rootmenu.el.nativeElement.contains(event.target); const isOutsideMenuButton = this.mobileActive && this.menubutton.nativeElement !== event.target && !this.menubutton.nativeElement.contains(event.target); - if (isOutsideContainer) { - isOutsideMenuButton ? (this.mobileActive = false) : this.hide(); + if (isOutsideContainer && isOutsideMenuButton) { + this.hide(); } }); }