diff --git a/CommonUI/src/Components/Dropdown/Dropdown.tsx b/CommonUI/src/Components/Dropdown/Dropdown.tsx index a876e5a964..bfffc81cc2 100644 --- a/CommonUI/src/Components/Dropdown/Dropdown.tsx +++ b/CommonUI/src/Components/Dropdown/Dropdown.tsx @@ -39,9 +39,44 @@ const Dropdown: FunctionComponent = ( | DropdownValue | DropdownOption | Array + | Array ): DropdownOption | Array => { - if (Array.isArray(value)) { - return value; + if ( + Array.isArray(value) && + value.length > 0 && + Object.keys(value[0]!).includes('value') + ) { + return value as Array; + } + + if ( + Array.isArray(value) && + value.length > 0 && + typeof value[0] === 'string' + ) { + const options: Array = []; + + for (const item of value as Array) { + if ( + (!Array.isArray(item) && typeof item === 'string') || + typeof item === 'number' + ) { + const option: + | DropdownOption + | undefined + | Array = props.options.find( + (option: DropdownOption) => { + return option.value === item; + } + ) as DropdownOption | Array; + + if (option) { + options.push(option as DropdownOption); + } + } + } + + return options; } if ( @@ -52,6 +87,7 @@ const Dropdown: FunctionComponent = ( return option.value === value; }) as DropdownOption | Array; } + return value as DropdownOption | Array; };