Skip to content

Commit

Permalink
Fixed #15240 - Menubar | The bug where the menuitems don't close when…
Browse files Browse the repository at this point in the history
… clicking outside the menuitem in mobile mode
  • Loading branch information
mehmetcetin01140 committed May 21, 2024
1 parent c42b73b commit f33a998
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/app/components/menubar/menubar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
}
});
}
Expand Down

0 comments on commit f33a998

Please sign in to comment.