diff --git a/packages/conform-dom/form.ts b/packages/conform-dom/form.ts index dabe32f5..e8df30b5 100644 --- a/packages/conform-dom/form.ts +++ b/packages/conform-dom/form.ts @@ -789,8 +789,13 @@ export function createFormContext< submitter, }); - if (submission.status !== 'success' && submission.error !== null) { - report(submission.reply()); + if (submission.status === 'success' || submission.error !== null) { + const result = submission.reply(); + + report({ + ...result, + status: result.status !== 'success' ? result.status : undefined, + }); } return { ...result, submission }; diff --git a/packages/conform-react/context.tsx b/packages/conform-react/context.tsx index aabf51f4..f460951a 100644 --- a/packages/conform-react/context.tsx +++ b/packages/conform-react/context.tsx @@ -15,6 +15,7 @@ import { getPaths, isPrefix, STATE, + INTENT, } from '@conform-to/dom'; import { type FormEvent, @@ -466,13 +467,15 @@ export function createFormContext< const result = context.submit(submitEvent); if ( - result.submission && - result.submission.status !== 'success' && - result.submission.error !== null + !result.submission || + result.submission.status === 'success' || + result.submission.error === null ) { - event.preventDefault(); + if (!result.formData.has(INTENT)) { + onSubmit?.(event, result); + } } else { - onSubmit?.(event, result); + event.preventDefault(); } }, onUpdate(options) {