Skip to content

Commit

Permalink
fix(de form custom attributes): use empty string instead of undefined…
Browse files Browse the repository at this point in the history
… when removing value
  • Loading branch information
Mohammer5 committed Nov 22, 2023
1 parent 8045ade commit 2cd895e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/pages/dataElements/fields/CustomAttributes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ type CustomAttributeProps = {
function CustomAttribute({ attribute, index }: CustomAttributeProps) {
const name = `attributeValues[${index}].value`
const required = attribute.mandatory
// If we don't do this, then RFF will set this value to undefined instead
// of an empty string
const parse = (value: string) => value || ''

if (attribute.optionSet?.options) {
const options = attribute.optionSet?.options.map(
Expand All @@ -43,6 +46,7 @@ function CustomAttribute({ attribute, index }: CustomAttributeProps) {
label={attribute.displayFormName}
name={name}
options={options}
parse={parse}
/>
</StandardFormSection>
)
Expand All @@ -57,6 +61,7 @@ function CustomAttribute({ attribute, index }: CustomAttributeProps) {
inputWidth={inputWidth}
label={attribute.displayFormName}
name={name}
parse={parse}
/>
</StandardFormSection>
)
Expand All @@ -71,6 +76,7 @@ function CustomAttribute({ attribute, index }: CustomAttributeProps) {
inputWidth={inputWidth}
label={attribute.displayFormName}
name={name}
parse={parse}
/>
</StandardFormSection>
)
Expand Down

0 comments on commit 2cd895e

Please sign in to comment.