Skip to content

Commit

Permalink
Update createFormControl.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
bluebill1049 committed May 18, 2024
1 parent 6289a66 commit 1a9e940
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/logic/createFormControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1098,17 +1098,19 @@ export function createFormControl<
iterateFieldsByAction(
_fields,
(ref, name) => {
let requiredDisabledState = disabled;
const currentField = get(_fields, name);
if (currentField && isBoolean(currentField._f.disabled)) {
requiredDisabledState ||= currentField._f.disabled;
const currentField: Field = get(_fields, name);
if (currentField) {
ref.disabled = currentField._f.disabled || disabled;

if (Array.isArray(currentField._f.refs)) {
currentField._f.refs.forEach((inputRef) => {
inputRef.disabled = currentField._f.disabled || disabled;
});
}
}

ref.disabled = requiredDisabledState;
},
0,
false,
true,
);
}
};
Expand Down

0 comments on commit 1a9e940

Please sign in to comment.