Skip to content

Commit b3e3c45

Browse files
committed
Menubar close in second click
1 parent e99e144 commit b3e3c45

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

.editorconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ root = true
44
[*]
55
charset = utf-8
66
indent_style = space
7-
indent_size = 2
7+
indent_size = 4
88
insert_final_newline = true
99
trim_trailing_whitespace = true
1010

src/app/components/menubar/menubar.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ export class MenubarSub implements OnDestroy {
5656
activeItem: any;
5757

5858
hideTimeout: any;
59+
60+
activeMenu: any;
5961

6062
constructor(public domHandler: DomHandler, public renderer: Renderer2) { }
6163

@@ -65,8 +67,8 @@ export class MenubarSub implements OnDestroy {
6567
if (menuitem.disabled) {
6668
return;
6769
}
68-
69-
this.activeItem = item;
70+
71+
this.activeItem = this.activeMenu ? (this.activeMenu.isEqualNode(item)? null: item) : item;
7072
let nextElement = <HTMLLIElement>item.children[0].nextElementSibling;
7173
if (nextElement) {
7274
let sublist = <HTMLUListElement>nextElement.children[0];
@@ -85,7 +87,8 @@ export class MenubarSub implements OnDestroy {
8587
}
8688

8789
this.menuClick = true;
88-
this.menuHoverActive = true;
90+
this.menuHoverActive = this.activeMenu ? (!this.activeMenu.isEqualNode(item)) : true;
91+
this.activeMenu = this.activeMenu ? (this.activeMenu.isEqualNode(item)? null: item) : item;
8992
this.bindEventListener();
9093
}
9194
}
@@ -128,6 +131,8 @@ export class MenubarSub implements OnDestroy {
128131
sublist.style.left = this.domHandler.getOuterWidth(item.children[0]) + 'px';
129132
}
130133
}
134+
135+
this.activeMenu = this.activeMenu ? (this.activeMenu.isEqualNode(item)? null: item) : item;
131136
}
132137
}
133138

0 commit comments

Comments
 (0)