Merge pull request #1770 from payloadcms/fix/#1762-select-unmatched-value

fix: #1762 select field crash on missing value option
This commit is contained in:
James Mikrut
2023-01-02 10:28:57 -05:00
committed by GitHub

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,
};
}