Skip to content

Commit

Permalink
Fix defaultValue overriding falsy values
Browse files Browse the repository at this point in the history
  • Loading branch information
pedro-lb committed Jul 7, 2020
1 parent 3914b33 commit 2de4f11
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/core/src/components/FormInput/FormInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,16 @@ const FormInput = ({
error: formInputError.hasErrors,
};

const inputValue = value ?? defaultValue ?? formInputMeta.initialValue;

const isUntouched = (
(value || defaultValue || formInputMeta.initialValue)
!!inputValue
&& !formInputMeta.touched
&& !isInitializedRef.current
);

if (isUntouched) {
form.setFieldValue(name, value || defaultValue || formInputMeta.initialValue);
form.setFieldValue(name, inputValue);

inputProps.defaultValue = undefined;
isInitializedRef.current = true;
Expand Down

0 comments on commit 2de4f11

Please sign in to comment.