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 Oct 2, 2024
1 parent 2825931 commit 08c5272
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/components/formio/textfield.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import clsx from 'clsx';
import {Field, useFormikContext} from 'formik';
import {useContext, useRef} from 'react';
import {useContext, useEffect, useRef} from 'react';

import {RenderContext} from '@/context';
import CharCount from '@/utils/charcount';
Expand Down Expand Up @@ -48,10 +48,13 @@ export const TextField: React.FC<JSX.IntrinsicElements['input'] & TextFieldProps
props = {...props, value: ''};
}

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


// 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
Expand Down

0 comments on commit 08c5272

Please sign in to comment.