Skip to content
Snippets Groups Projects
Commit 020e9953 authored by Yannis Barlas's avatar Yannis Barlas
Browse files

fix(ui): handle empty value in form builder select

parent ddd950d0
No related branches found
No related tags found
No related merge requests found
import React, { useState } from 'react'
import PropTypes from 'prop-types'
import { map, omitBy } from 'lodash'
import { ValidatedFieldFormik, Menu, Button } from '@pubsweet/ui'
import { isEmpty, map, omitBy } from 'lodash'
import { Formik } from 'formik'
import { ValidatedFieldFormik, Menu, Button } from '@pubsweet/ui'
import FormProperties from './FormProperties'
import components from './config/Elements'
import * as elements from './builderComponents'
......@@ -50,9 +52,14 @@ const ComponentProperties = ({
component={elements[value.component].default}
key={`${selectedComponent}-${key}`}
name={key}
onChange={val =>
onChange={val => {
if (isEmpty(val)) {
setFieldValue(key, null)
return
}
setFieldValue(key, val.target ? val.target.value : val)
}
}}
{...value.props}
/>
</Section>
......
......@@ -24,6 +24,7 @@ const ValidationMenu = input => (
</Section>
)
}
return null
})}
</>
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment