improve dropdown autopopulation behavior (#23420)

This commit is contained in:
brian-harris
2023-06-20 07:45:00 -07:00
committed by GitHub
parent f36ed0bb02
commit 6e014aff92
6 changed files with 94 additions and 71 deletions

View File

@@ -241,9 +241,9 @@ export function selectDefaultDropdownValue(dropDown: DropDownComponent, value?:
if (value) {
const searchValue = value.toLowerCase();
if (useDisplayName) {
selectedIndex = dropDown.values.findIndex((v: any) => (v as CategoryValue)?.displayName?.toLowerCase() === searchValue);
selectedIndex = dropDown.values?.findIndex((v: any) => (v as CategoryValue)?.displayName?.toLowerCase() === searchValue);
} else {
selectedIndex = dropDown.values.findIndex((v: any) => (v as CategoryValue)?.name?.toLowerCase() === searchValue);
selectedIndex = dropDown.values?.findIndex((v: any) => (v as CategoryValue)?.name?.toLowerCase() === searchValue);
}
} else {
selectedIndex = -1;
@@ -1169,7 +1169,7 @@ export function createRegistrationInstructions(view: ModelView, testConnectionBu
}).component();
}
export function clearDropDown(dropDown: DropDownComponent): void {
dropDown.values = [];
dropDown.value = undefined;
export async function clearDropDown(dropDown: DropDownComponent): Promise<void> {
await dropDown.updateProperty('value', undefined);
await dropDown.updateProperty('values', []);
}