fix: select field crash on missing value option

This commit is contained in:
Dan Ribbens
2022-12-26 12:13:11 -05:00
parent 7b92211eca
commit ec9196e33c

View File

@@ -65,15 +65,15 @@ const SelectInput: React.FC<SelectInputProps> = (props) => {
valueToRender = value.map((val) => {
const matchingOption = options.find((option) => option.value === val);
return {
label: getTranslation(matchingOption.label, i18n),
value: matchingOption.value,
label: matchingOption ? getTranslation(matchingOption.label, i18n) : val,
value: matchingOption?.value ?? val,
};
});
} else if (value) {
const matchingOption = options.find((option) => option.value === value);
valueToRender = {
label: getTranslation(matchingOption.label, i18n),
value: matchingOption.value,
label: matchingOption ? getTranslation(matchingOption.label, i18n) : value,
value: matchingOption?.value ?? value,
};
}