diff --git a/src/vs/base/browser/dom.ts b/src/vs/base/browser/dom.ts index 3e5eaeaa4fa..d5622349ff0 100644 --- a/src/vs/base/browser/dom.ts +++ b/src/vs/base/browser/dom.ts @@ -820,6 +820,7 @@ export function isHTMLElement(o: any): o is HTMLElement { export const EventType = { // Mouse CLICK: 'click', + AUXCLICK: 'auxclick', DBLCLICK: 'dblclick', MOUSE_UP: 'mouseup', MOUSE_DOWN: 'mousedown', diff --git a/src/vs/workbench/browser/parts/editor/editorGroupView.ts b/src/vs/workbench/browser/parts/editor/editorGroupView.ts index dcf07d6ebaf..0bf99cb44ea 100644 --- a/src/vs/workbench/browser/parts/editor/editorGroupView.ts +++ b/src/vs/workbench/browser/parts/editor/editorGroupView.ts @@ -275,9 +275,9 @@ export class EditorGroupView extends Themable implements IEditorGroupView { })); // Close empty editor group via middle mouse click - this._register(addDisposableListener(this.element, EventType.MOUSE_UP, e => { + this._register(addDisposableListener(this.element, EventType.AUXCLICK, e => { if (this.isEmpty && e.button === 1 /* Middle Button */) { - EventHelper.stop(e); + EventHelper.stop(e, true); this.accessor.removeGroup(this); } diff --git a/src/vs/workbench/browser/parts/editor/noTabsTitleControl.ts b/src/vs/workbench/browser/parts/editor/noTabsTitleControl.ts index e309691bcf4..f96ff3982d2 100644 --- a/src/vs/workbench/browser/parts/editor/noTabsTitleControl.ts +++ b/src/vs/workbench/browser/parts/editor/noTabsTitleControl.ts @@ -67,10 +67,10 @@ export class NoTabsTitleControl extends TitleControl { this._register(addDisposableListener(titleContainer, EventType.DBLCLICK, (e: MouseEvent) => this.onTitleDoubleClick(e))); // Detect mouse click - this._register(addDisposableListener(titleContainer, EventType.MOUSE_UP, (e: MouseEvent) => this.onTitleClick(e))); + this._register(addDisposableListener(titleContainer, EventType.AUXCLICK, (e: MouseEvent) => this.onTitleAuxClick(e))); // Detect touch - this._register(addDisposableListener(titleContainer, TouchEventType.Tap, (e: GestureEvent) => this.onTitleClick(e))); + this._register(addDisposableListener(titleContainer, TouchEventType.Tap, (e: GestureEvent) => this.onTitleTap(e))); // Context Menu this._register(addDisposableListener(titleContainer, EventType.CONTEXT_MENU, (e: Event) => { @@ -98,25 +98,21 @@ export class NoTabsTitleControl extends TitleControl { this.group.pinEditor(); } - private onTitleClick(e: MouseEvent | GestureEvent): void { - if (e instanceof MouseEvent) { - // Close editor on middle mouse click - if (e.button === 1 /* Middle Button */) { - EventHelper.stop(e, true /* for https://github.com/Microsoft/vscode/issues/56715 */); + private onTitleAuxClick(e: MouseEvent): void { + if (e.button === 1 /* Middle Button */ && this.group.activeEditor) { + EventHelper.stop(e, true /* for https://github.com/Microsoft/vscode/issues/56715 */); - if (this.group.activeEditor) { - this.group.closeEditor(this.group.activeEditor); - } - } - } else { - // TODO@rebornix - // gesture tap should open the quick access - // editorGroupView will focus on the editor again when there are mouse/pointer/touch down events - // we need to wait a bit as `GesureEvent.Tap` is generated from `touchstart` and then `touchend` evnets, which are not an atom event. - setTimeout(() => this.quickInputService.quickAccess.show(), 50); + this.group.closeEditor(this.group.activeEditor); } } + private onTitleTap(e: GestureEvent): void { + // TODO@rebornix gesture tap should open the quick access + // editorGroupView will focus on the editor again when there are mouse/pointer/touch down events + // we need to wait a bit as `GesureEvent.Tap` is generated from `touchstart` and then `touchend` evnets, which are not an atom event. + setTimeout(() => this.quickInputService.quickAccess.show(), 50); + } + getPreferredHeight(): number { return EDITOR_TITLE_HEIGHT; } diff --git a/src/vs/workbench/browser/parts/editor/tabsTitleControl.ts b/src/vs/workbench/browser/parts/editor/tabsTitleControl.ts index 203f334180d..9da7e6b3488 100644 --- a/src/vs/workbench/browser/parts/editor/tabsTitleControl.ts +++ b/src/vs/workbench/browser/parts/editor/tabsTitleControl.ts @@ -601,8 +601,6 @@ export class TabsTitleControl extends TitleControl { const disposables = new DisposableStore(); const handleClickOrTouch = (e: MouseEvent | GestureEvent): void => { - tab.blur(); - if (e instanceof MouseEvent && e.button !== 0) { if (e.button === 1) { e.preventDefault(); // required to prevent auto-scrolling (https://github.com/Microsoft/vscode/issues/16690) @@ -643,13 +641,9 @@ export class TabsTitleControl extends TitleControl { })); // Close on mouse middle click - disposables.add(addDisposableListener(tab, EventType.MOUSE_UP, (e: MouseEvent) => { - EventHelper.stop(e); - - tab.blur(); - + disposables.add(addDisposableListener(tab, EventType.AUXCLICK, (e: MouseEvent) => { if (e.button === 1 /* Middle Button*/) { - e.stopPropagation(); // for https://github.com/Microsoft/vscode/issues/56715 + EventHelper.stop(e, true /* for https://github.com/Microsoft/vscode/issues/56715 */); this.blockRevealActiveTabOnce(); this.closeOneEditorAction.run({ groupId: this.group.id, editorIndex: index }); diff --git a/src/vs/workbench/browser/parts/notifications/notificationsViewer.ts b/src/vs/workbench/browser/parts/notifications/notificationsViewer.ts index f78cee5dd95..4b213eb468a 100644 --- a/src/vs/workbench/browser/parts/notifications/notificationsViewer.ts +++ b/src/vs/workbench/browser/parts/notifications/notificationsViewer.ts @@ -307,9 +307,9 @@ export class NotificationTemplateRenderer extends Disposable { // Container toggleClass(this.template.container, 'expanded', notification.expanded); - this.inputDisposables.add(addDisposableListener(this.template.container, EventType.MOUSE_UP, e => { + this.inputDisposables.add(addDisposableListener(this.template.container, EventType.AUXCLICK, e => { if (!notification.hasProgress && e.button === 1 /* Middle Button */) { - EventHelper.stop(e); + EventHelper.stop(e, true); notification.close(); }