This commit is contained in:
Megan Rogge 2021-04-28 12:05:15 -07:00 committed by GitHub
parent 968d670266
commit 2f5e355bea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 61 additions and 10 deletions

View file

@ -21,16 +21,16 @@
}
.monaco-dropdown-with-primary {
display: flex;
display: flex !important;
flex-direction: row;
border-radius: 5px;
}
.monaco-dropdown-with-primary > .action-label {
.monaco-dropdown-with-primary > .action-container > .action-label {
margin-right: 0;
}
.monaco-dropdown-with-primary > .monaco-dropdown > .dropdown-label .codicon[class*='codicon-'] {
.monaco-dropdown-with-primary > .dropdown-action-container > .monaco-dropdown > .dropdown-label .codicon[class*='codicon-'] {
font-size: 12px;
padding-left: 0px;
padding-right: 0px;

View file

@ -8,17 +8,21 @@ import { ActionViewItem, BaseActionViewItem } from 'vs/base/browser/ui/actionbar
import { DropdownMenuActionViewItem } from 'vs/base/browser/ui/dropdown/dropdownActionViewItem';
import { IAction } from 'vs/base/common/actions';
import * as DOM from 'vs/base/browser/dom';
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { KeyCode } from 'vs/base/common/keyCodes';
import { dispose, IDisposable } from 'vs/base/common/lifecycle';
export class DropdownWithPrimaryActionViewItem extends BaseActionViewItem {
private _primaryAction: ActionViewItem;
private _dropdown: DropdownMenuActionViewItem;
private _container: HTMLElement | null = null;
private toDispose: IDisposable[];
constructor(
primaryAction: IAction,
dropdownAction: IAction,
dropdownMenuActions: IAction[],
private readonly _className: string,
_className: string,
private readonly _contextMenuProvider: IContextMenuProvider,
dropdownIcon?: string
) {
@ -30,16 +34,63 @@ export class DropdownWithPrimaryActionViewItem extends BaseActionViewItem {
this._dropdown = new DropdownMenuActionViewItem(dropdownAction, dropdownMenuActions, this._contextMenuProvider, {
menuAsChild: true
});
this.toDispose = [];
}
override render(container: HTMLElement): void {
this._container = container;
super.render(this._container);
this.element = DOM.append(this._container, DOM.$(''));
this.element.className = this._className;
this.element.classList.add('monaco-dropdown-with-primary');
this._primaryAction.render(this.element);
this._dropdown.render(this.element);
this._container.classList.add('monaco-dropdown-with-primary');
const primaryContainer = DOM.$('.action-container');
this._primaryAction.render(DOM.append(this._container, primaryContainer));
const dropdownContainer = DOM.$('.dropdown-action-container');
this._dropdown.render(DOM.append(this._container, dropdownContainer));
this.toDispose.push(DOM.addDisposableListener(primaryContainer, DOM.EventType.KEY_DOWN, (e: KeyboardEvent) => {
const event = new StandardKeyboardEvent(e);
if (event.equals(KeyCode.RightArrow)) {
this._primaryAction.element!.tabIndex = -1;
this._dropdown.focus();
event.stopPropagation();
}
}));
this.toDispose.push(DOM.addDisposableListener(dropdownContainer, DOM.EventType.KEY_DOWN, (e: KeyboardEvent) => {
const event = new StandardKeyboardEvent(e);
if (event.equals(KeyCode.LeftArrow)) {
this._primaryAction.element!.tabIndex = 0;
this._dropdown.setFocusable(false);
this._primaryAction.element?.focus();
event.stopPropagation();
}
}));
}
override focus(fromRight?: boolean): void {
if (fromRight) {
this._dropdown.focus();
} else {
this._primaryAction.element!.tabIndex = 0;
this._primaryAction.element!.focus();
}
}
override blur(): void {
this._primaryAction.element!.tabIndex = -1;
this._dropdown.blur();
this._container!.blur();
}
override setFocusable(focusable: boolean): void {
if (focusable) {
this._primaryAction.element!.tabIndex = 0;
} else {
this._primaryAction.element!.tabIndex = -1;
this._dropdown.setFocusable(false);
}
}
override dispose(): void {
this.toDispose = dispose(this.toDispose);
}
update(dropdownAction: IAction, dropdownMenuActions: IAction[], dropdownIcon?: string): void {

View file

@ -150,7 +150,7 @@ export class TerminalTabbedView extends Disposable {
private _shouldShowTabs(): boolean {
const enable = this._terminalService.configHelper.config.tabs.enabled;
const hideForSingle = this._terminalService.configHelper.config.tabs.hideCondition === 'singleTerminal';
const hideForSingle = this._terminalService.configHelper.config.tabs.showActiveTerminal === 'singleTerminal';
return enable && (!hideForSingle || (hideForSingle && this._terminalService.terminalInstances.length > 1));
}