Skip to content

Commit ec9196e

Browse files
committed
fix: select field crash on missing value option
1 parent 7b92211 commit ec9196e

File tree

1 file changed

+4
-4
lines changed
  • src/admin/components/forms/field-types/Select

1 file changed

+4
-4
lines changed

src/admin/components/forms/field-types/Select/Input.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@ const SelectInput: React.FC<SelectInputProps> = (props) => {
6565
valueToRender = value.map((val) => {
6666
const matchingOption = options.find((option) => option.value === val);
6767
return {
68-
label: getTranslation(matchingOption.label, i18n),
69-
value: matchingOption.value,
68+
label: matchingOption ? getTranslation(matchingOption.label, i18n) : val,
69+
value: matchingOption?.value ?? val,
7070
};
7171
});
7272
} else if (value) {
7373
const matchingOption = options.find((option) => option.value === value);
7474
valueToRender = {
75-
label: getTranslation(matchingOption.label, i18n),
76-
value: matchingOption.value,
75+
label: matchingOption ? getTranslation(matchingOption.label, i18n) : value,
76+
value: matchingOption?.value ?? value,
7777
};
7878
}
7979

0 commit comments

Comments
 (0)