Skip to content

Commit

Permalink
🐞 fix #11292 issue with controller validation prop (#11294)
Browse files Browse the repository at this point in the history
* fix #11292 issue with controller valdiation prop

* remove log
  • Loading branch information
bluebill1049 authored Dec 13, 2023
1 parent 7f56c6e commit 28d0d93
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/logic/createFormControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,9 @@ export function createFormControl<
const output: Partial<FormState<TFieldValues>> & { name: string } = {
name,
};
const disabledField = get(_fields, name) && get(_fields, name)._f.disabled;
const disabledField = !!(
get(_fields, name) && get(_fields, name)._f.disabled
);

if (!isBlurEvent || shouldDirty) {
if (_proxyFormState.isDirty) {
Expand All @@ -310,7 +312,7 @@ export function createFormControl<
const isCurrentFieldPristine =
disabledField || deepEqual(get(_defaultValues, name), fieldValue);

isPreviousDirty = !disabledField && get(_formState.dirtyFields, name);
isPreviousDirty = !!(!disabledField && get(_formState.dirtyFields, name));
isCurrentFieldPristine || disabledField
? unset(_formState.dirtyFields, name)
: set(_formState.dirtyFields, name, true);
Expand Down Expand Up @@ -998,6 +1000,7 @@ export function createFormControl<
field,
disabled: options.disabled,
name,
value: options.value,
});
} else {
updateValidAndValue(name, true, options.value);
Expand Down

0 comments on commit 28d0d93

Please sign in to comment.