fix the empty schema issue (#22594) (#22597)

This commit is contained in:
Alan Ren
2023-04-03 16:04:54 -07:00
committed by GitHub
parent a8d851b1ed
commit d1b18a2ee6

View File

@@ -286,14 +286,17 @@ export abstract class ObjectManagementDialogBase<ObjectInfoType extends ObjectMa
protected createDropdown(ariaLabel: string, values: string[], value: string | undefined, enabled: boolean = true, width: number = DefaultInputWidth): azdata.DropDownComponent { protected createDropdown(ariaLabel: string, values: string[], value: string | undefined, enabled: boolean = true, width: number = DefaultInputWidth): azdata.DropDownComponent {
// Automatically add an empty item to the beginning of the list if the current value is not specified. // Automatically add an empty item to the beginning of the list if the current value is not specified.
// This is needed when no meaningful default value can be provided. // This is needed when no meaningful default value can be provided.
// Create a new array so that the original array isn't modified.
const dropdownValues = [];
dropdownValues.push(...values);
if (!value) { if (!value) {
values.unshift(''); dropdownValues.unshift('');
} }
return this.modelView.modelBuilder.dropDown().withProps({ return this.modelView.modelBuilder.dropDown().withProps({
ariaLabel: ariaLabel, ariaLabel: ariaLabel,
values: values, values: dropdownValues,
value: value, value: value,
width: DefaultInputWidth, width: width,
enabled: enabled enabled: enabled
}).component(); }).component();
} }