Fixes select box issue (#9808)

* Fixes select box issue

* Flip the if statement

* length check and error

* Theres apparently 0 length arrays using this

* Remove length check
This commit is contained in:
Amir Omidi
2020-03-31 11:13:15 -07:00
committed by GitHub
parent d832839b23
commit 1203c3b211

View File

@@ -38,6 +38,8 @@ export interface ISelectBoxStyles extends vsISelectBoxStyles {
inputValidationErrorForeground?: Color; inputValidationErrorForeground?: Color;
} }
export class SelectBoxEmptyError extends Error { }
export class SelectBox extends vsSelectBox { export class SelectBox extends vsSelectBox {
private _optionsDictionary: Map<string, number>; private _optionsDictionary: Map<string, number>;
private _dialogOptions: SelectOptionItemSQL[]; private _dialogOptions: SelectOptionItemSQL[];
@@ -66,12 +68,13 @@ export class SelectBox extends vsSelectBox {
constructor(options: SelectOptionItemSQL[] | string[], selectedOption: string, contextViewProvider: IContextViewProvider, container?: HTMLElement, selectBoxOptions?: ISelectBoxOptions) { constructor(options: SelectOptionItemSQL[] | string[], selectedOption: string, contextViewProvider: IContextViewProvider, container?: HTMLElement, selectBoxOptions?: ISelectBoxOptions) {
let optionItems: SelectOptionItemSQL[]; let optionItems: SelectOptionItemSQL[];
if (Array.isArray<string>(options)) {
optionItems = (options as string[]).map(o => { if (Array.isArray<string>(options) && typeof (options[0]) === 'string') {
optionItems = (options).map(o => {
return { text: o, value: o } as SelectOptionItemSQL; return { text: o, value: o } as SelectOptionItemSQL;
}); });
} else { } else {
optionItems = options; optionItems = options as SelectOptionItemSQL[];
} }
super(optionItems, 0, contextViewProvider, undefined, selectBoxOptions); super(optionItems, 0, contextViewProvider, undefined, selectBoxOptions);