From 2cd895e47f3de2019c6c002210cef69230a77fc8 Mon Sep 17 00:00:00 2001 From: Jan-Gerke Salomon Date: Wed, 22 Nov 2023 16:53:43 +0100 Subject: [PATCH] fix(de form custom attributes): use empty string instead of undefined when removing value --- src/pages/dataElements/fields/CustomAttributes.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/pages/dataElements/fields/CustomAttributes.tsx b/src/pages/dataElements/fields/CustomAttributes.tsx index 92539a68..780971e9 100644 --- a/src/pages/dataElements/fields/CustomAttributes.tsx +++ b/src/pages/dataElements/fields/CustomAttributes.tsx @@ -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( @@ -43,6 +46,7 @@ function CustomAttribute({ attribute, index }: CustomAttributeProps) { label={attribute.displayFormName} name={name} options={options} + parse={parse} /> ) @@ -57,6 +61,7 @@ function CustomAttribute({ attribute, index }: CustomAttributeProps) { inputWidth={inputWidth} label={attribute.displayFormName} name={name} + parse={parse} /> ) @@ -71,6 +76,7 @@ function CustomAttribute({ attribute, index }: CustomAttributeProps) { inputWidth={inputWidth} label={attribute.displayFormName} name={name} + parse={parse} /> )