Skip to content

Commit

Permalink
🥊 improve native reset API invoke (#9293)
Browse files Browse the repository at this point in the history
  • Loading branch information
bluebill1049 authored Oct 28, 2022
1 parent b07cb30 commit e5cc38a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/logic/createFormControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1140,12 +1140,13 @@ export function createFormControl<
? field._f.refs[0]
: field._f.ref;

try {
if (isHTMLElement(fieldReference)) {
fieldReference.closest('form')!.reset();
if (isHTMLElement(fieldReference)) {
const form = fieldReference.closest('form');
if (form) {
form.reset();
break;
}
} catch {}
}
}
}
}
Expand Down

0 comments on commit e5cc38a

Please sign in to comment.