Skip to content

Commit

Permalink
fix: add fallback if requestSubmit is not available (#227)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefl authored Oct 15, 2024
1 parent d1b0619 commit e9b02c6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion apps/nextjs/src/lib/hooks/use-enter-submit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@ export function useEnterSubmit(): {
!event.nativeEvent.isComposing
) {
try {
formRef.current?.requestSubmit();
if (formRef.current?.requestSubmit) {
formRef.current.requestSubmit();
} else if (formRef.current?.submit) {
formRef.current.submit();
} else {
throw new Error("Form submission not supported");
}
} catch (error) {
console.error("Failed to submit form:", error);
}
Expand Down

0 comments on commit e9b02c6

Please sign in to comment.