From ec9196e33ca01e6a15097943b4be6dee6ea5202f Mon Sep 17 00:00:00 2001 From: Dan Ribbens Date: Mon, 26 Dec 2022 12:13:11 -0500 Subject: [PATCH] fix: select field crash on missing value option --- src/admin/components/forms/field-types/Select/Input.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/admin/components/forms/field-types/Select/Input.tsx b/src/admin/components/forms/field-types/Select/Input.tsx index ee9bf04337..b8b2e025a7 100644 --- a/src/admin/components/forms/field-types/Select/Input.tsx +++ b/src/admin/components/forms/field-types/Select/Input.tsx @@ -65,15 +65,15 @@ const SelectInput: React.FC = (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, }; }