Skip to content

Commit

Permalink
🐛 [open-formulieren/open-forms#4659] Ensure that textfield have a val…
Browse files Browse the repository at this point in the history
…id empty value
  • Loading branch information
robinmolen committed Sep 26, 2024
1 parent 42f1e1f commit 26daac4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/components/formio/textfield.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const TextField: React.FC<JSX.IntrinsicElements['input'] & TextFieldProps
childrenAfterField,
...props
}) => {
const {getFieldProps, getFieldMeta} = useFormikContext();
const {getFieldProps, getFieldMeta, setFieldValue} = useFormikContext();
const {value, onChange: formikOnChange} = getFieldProps<string | undefined>(name);
const {touched} = getFieldMeta<string | undefined>(name);
const {errors, hasErrors} = useValidationErrors(name);
Expand All @@ -48,6 +48,11 @@ export const TextField: React.FC<JSX.IntrinsicElements['input'] & TextFieldProps
props = {...props, value: ''};
}

if (value === undefined || value === null) {
// Make sure value is valid
setFieldValue(name, '');
}

// XXX: this is only accepted in the form builder to get to (close to) vanilla form
// builder feature parity - setting the value with mask placeholders is bad for
// accessibility.
Expand Down

0 comments on commit 26daac4

Please sign in to comment.