Skip to content

Commit 01deee1

Browse files
committed
Fix required dimensions component to read/write formik state properly
1 parent 63a268a commit 01deee1

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

datajunction-ui/src/app/pages/AddEditNodePage/FormikSelect.jsx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,29 @@ export const FormikSelect = ({
3939
}
4040
};
4141

42+
// Convert Formik field value to React Select format
43+
const getSelectValue = () => {
44+
if (!field.value) {
45+
return isMulti ? [] : null;
46+
}
47+
48+
if (isMulti) {
49+
// For multi-select, map array of values to option objects
50+
return Array.isArray(field.value)
51+
? field.value.map(val =>
52+
selectOptions.find(opt => opt.value === val) || { value: val, label: val }
53+
)
54+
: [];
55+
} else {
56+
// For single-select, find the matching option
57+
return selectOptions.find(opt => opt.value === field.value) || null;
58+
}
59+
};
60+
4261
return (
4362
<Select
4463
className={className}
45-
defaultValue={defaultValue}
64+
value={getSelectValue()}
4665
options={selectOptions}
4766
name={field.name}
4867
placeholder={placeholder}

0 commit comments

Comments
 (0)