Skip to content

Commit

Permalink
#18
Browse files Browse the repository at this point in the history
  • Loading branch information
michitaro committed Apr 13, 2019
1 parent 5667666 commit 2a16018
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/rootlessmenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ import { MenuType, Direction } from "./menu/script"
import { once } from "./event"
import { MENUBARITEM_KEY } from "./menubaritem/script";

export const openedRootlessMenus: RootlessMenu[] = []

function closeOthres() {
while (openedRootlessMenus.length > 0) {
openedRootlessMenus.pop()!.close()
}
}

@Component({
components: { XMenu: Menu },
Expand Down Expand Up @@ -33,6 +40,8 @@ export class RootlessMenu extends Vue {

openMenu(mousedown: MouseEvent) {
mousedown.preventDefault()
closeOthres()
openedRootlessMenus.push(this)
this.clearCancellers()

if (this.menu().isOpen) {
Expand All @@ -56,7 +65,7 @@ export class RootlessMenu extends Vue {
this.menu().open(position.x, position.y, position.direction)
}

private close() {
close() {
this.clearCancellers()
const menu = this.menu()
menu && menu.close(true)
Expand Down

0 comments on commit 2a16018

Please sign in to comment.