提交 a857ee8f 编写于 作者: B Benjamin Pasero

Click on menus on explorer title bar collapses the explorer (fixes #27648)

上级 498beff5
......@@ -8,7 +8,7 @@
import 'vs/css!./dropdown';
import { Builder, $ } from 'vs/base/browser/builder';
import { TPromise } from 'vs/base/common/winjs.base';
import { Gesture, EventType } from 'vs/base/browser/touch';
import { Gesture, EventType as GestureEventType } from 'vs/base/browser/touch';
import { ActionRunner, IAction } from 'vs/base/common/actions';
import { IActionItem } from 'vs/base/browser/ui/actionbar/actionbar';
import { EventEmitter } from 'vs/base/common/eventEmitter';
......@@ -16,6 +16,7 @@ import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { IContextViewProvider } from 'vs/base/browser/ui/contextview/contextview';
import { IMenuOptions } from 'vs/base/browser/ui/menu/menu';
import { ResolvedKeybinding } from 'vs/base/common/keyCodes';
import { EventHelper, EventType } from "vs/base/browser/dom";
export interface ILabelRenderer {
(container: HTMLElement): IDisposable;
......@@ -50,11 +51,15 @@ export class BaseDropdown extends ActionRunner {
};
}
this.$label.on(['mousedown', EventType.Tap], (e: Event) => {
e.preventDefault();
e.stopPropagation();
this.show();
this.$label.on([EventType.CLICK, EventType.MOUSE_DOWN, GestureEventType.Tap], (e: Event) => {
EventHelper.stop(e, true); // prevent default click behaviour to trigger
}).on([EventType.MOUSE_DOWN, GestureEventType.Tap], (e: Event) => {
// We want to show the context menu on dropdown so that as a user you can press and hold the
// mouse button, make a choice of action in the menu and release the mouse to trigger that
// action.
// Due to some weird bugs though, we delay showing the menu to unwind event stack
// (see https://github.com/Microsoft/vscode/issues/27648)
setTimeout(() => this.show(), 100);
}).appendTo(this.$el);
let cleanupFn = labelRenderer(this.$label.getHTMLElement());
......
......@@ -99,6 +99,15 @@ export class ExplorerViewlet extends Viewlet {
if (this.views.length === 1) {
return this.views[0].getActions();
}
return [];
}
public getSecondaryActions(): IAction[] {
if (this.views.length === 1) {
return this.views[0].getSecondaryActions();
}
return [];
}
......
......@@ -131,7 +131,7 @@ export class ExplorerView extends CollapsibleViewletView {
this.tree = this.createViewer($(this.treeContainer));
if (this.toolBar) {
this.toolBar.setActions(prepareActions(this.getActions()), [])();
this.toolBar.setActions(prepareActions(this.getActions()), this.getSecondaryActions())();
}
const onFileIconThemeChange = (fileIconTheme: IFileIconTheme) => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册