Skip to content

Commit

Permalink
🐞 fix react-hook-form#11292 issue with controller validation prop (re…
Browse files Browse the repository at this point in the history
…act-hook-form#11294)

* fix react-hook-form#11292 issue with controller valdiation prop

* remove log
  • Loading branch information
bluebill1049 authored and rafaelcalhau committed May 5, 2024
1 parent c60158b commit 87093f6
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 @@ -1002,6 +1004,7 @@ export function createFormControl<
field,
disabled: options.disabled,
name,
value: options.value,
});
} else {
updateValidAndValue(name, true, options.value);
Expand Down

0 comments on commit 87093f6

Please sign in to comment.