Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
sbatten committed Aug 2, 2018
1 parent d91fdfd commit 49bce6d
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/vs/base/browser/ui/menu/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ class MenuActionItem extends BaseActionItem {
class SubmenuActionItem extends MenuActionItem {
private mysubmenu: Menu;
private submenuContainer: Builder;
private mouseOver: boolean;
private showScheduler: RunOnceScheduler;
private hideScheduler: RunOnceScheduler;

constructor(
Expand All @@ -251,6 +253,13 @@ class SubmenuActionItem extends MenuActionItem {
) {
super(action, action, { label: true, isMenu: true });

this.showScheduler = new RunOnceScheduler(() => {
if (this.mouseOver) {
this.cleanupExistingSubmenu(false);
this.createSubmenu(false);
}
}, 250);

this.hideScheduler = new RunOnceScheduler(() => {
if ((!isAncestor(document.activeElement, this.builder.getHTMLElement()) && this.parentData.submenu === this.mysubmenu)) {
this.parentData.parent.focus(false);
Expand Down Expand Up @@ -283,8 +292,15 @@ class SubmenuActionItem extends MenuActionItem {
});

$(this.builder).on(EventType.MOUSE_OVER, (e) => {
this.cleanupExistingSubmenu(false);
this.createSubmenu(false);
if (!this.mouseOver) {
this.mouseOver = true;

this.showScheduler.schedule();
}
});

$(this.builder).on(EventType.MOUSE_LEAVE, (e) => {
this.mouseOver = false;
});

$(this.builder).on(EventType.FOCUS_OUT, (e) => {
Expand Down

0 comments on commit 49bce6d

Please sign in to comment.