Resend selectBox change to on against master. PR against nativeNotebook was approved already. (#3215)

This commit is contained in:
Yurong He
2018-11-14 13:48:41 -08:00
committed by GitHub
parent d7d4c7236c
commit 5889c600fa
6 changed files with 82 additions and 36 deletions

View File

@@ -4,6 +4,8 @@
*--------------------------------------------------------------------------------------------*/
'use strict';
import 'vs/css!./media/selectBox';
import { SelectBox as vsSelectBox, ISelectBoxStyles as vsISelectBoxStyles, ISelectBoxOptions } from 'vs/base/browser/ui/selectBox/selectBox';
import { Color } from 'vs/base/common/color';
import { IContextViewProvider, AnchorAlignment } from 'vs/base/browser/ui/contextview/contextview';
@@ -30,6 +32,7 @@ export class SelectBox extends vsSelectBox {
private _optionsDictionary;
private _dialogOptions: string[];
private _selectedOption: string;
private _selectBoxOptions: ISelectBoxOptions;
private enabledSelectBackground: Color;
private enabledSelectForeground: Color;
private enabledSelectBorder: Color;
@@ -72,6 +75,7 @@ export class SelectBox extends vsSelectBox {
// explicitly set the accessible role so that the screen readers can read the control type properly
this.selectElement.setAttribute('role', 'combobox');
this._selectBoxOptions = selectBoxOptions;
}
public style(styles: ISelectBoxStyles): void {
@@ -226,4 +230,34 @@ export class SelectBox extends vsSelectBox {
default: return { border: this.inputValidationErrorBorder, background: this.inputValidationErrorBackground };
}
}
}
public render(container: HTMLElement): void {
let selectOptions: ISelectBoxOptionsWithLabel = this._selectBoxOptions as ISelectBoxOptionsWithLabel;
if (selectOptions && selectOptions.labelText && selectOptions.labelText !== undefined) {
let outerContainer = document.createElement('div');
let selectContainer = document.createElement('div');
outerContainer.className = selectOptions.labelOnTop ? 'labelOnTopContainer' : 'labelOnLeftContainer';
let labelText = document.createElement('div');
labelText.className = 'action-item-label';
labelText.innerHTML = selectOptions.labelText;
container.appendChild(outerContainer);
outerContainer.appendChild(labelText);
outerContainer.appendChild(selectContainer);
super.render(selectContainer);
this.selectElement.classList.add('action-item-label');
}
else {
super.render(container);
}
}
}
export interface ISelectBoxOptionsWithLabel extends ISelectBoxOptions {
labelText?: string;
labelOnTop?: boolean;
}