diff --git a/src/logic/createFormControl.ts b/src/logic/createFormControl.ts index 344ab6b66c5..640293202d5 100644 --- a/src/logic/createFormControl.ts +++ b/src/logic/createFormControl.ts @@ -298,6 +298,7 @@ export function createFormControl< const output: Partial> & { name: string } = { name, }; + const disabledField = get(_fields, name) && get(_fields, name)._f.disabled; if (!isBlurEvent || shouldDirty) { if (_proxyFormState.isDirty) { @@ -306,13 +307,11 @@ export function createFormControl< shouldUpdateField = isPreviousDirty !== output.isDirty; } - const isCurrentFieldPristine = deepEqual( - get(_defaultValues, name), - fieldValue, - ); + const isCurrentFieldPristine = + disabledField || deepEqual(get(_defaultValues, name), fieldValue); - isPreviousDirty = get(_formState.dirtyFields, name); - isCurrentFieldPristine + isPreviousDirty = !disabledField && get(_formState.dirtyFields, name); + isCurrentFieldPristine || disabledField ? unset(_formState.dirtyFields, name) : set(_formState.dirtyFields, name, true); output.dirtyFields = _formState.dirtyFields;