diff --git a/apps/spotlight/src/features/form-page/components/AppFormPage.tsx b/apps/spotlight/src/features/form-page/components/AppFormPage.tsx index 107afd65..499a9092 100644 --- a/apps/spotlight/src/features/form-page/components/AppFormPage.tsx +++ b/apps/spotlight/src/features/form-page/components/AppFormPage.tsx @@ -61,7 +61,9 @@ const AppFormRoute = () => { uswdsRoot: ctx.uswdsRoot, }} session={formSessionResponse.formSession} - onSubmit={data => actions.onSubmitForm({ formId: id, data })} + onSubmit={data => { + actions.onSubmitForm({ formId: id, data }); + }} /> )} diff --git a/packages/design/src/Form/index.tsx b/packages/design/src/Form/index.tsx index 1ccd98fe..683bb700 100644 --- a/packages/design/src/Form/index.tsx +++ b/packages/design/src/Form/index.tsx @@ -106,10 +106,22 @@ export default function Form({ className="usa-form margin-bottom-3 maxw-full" onSubmit={ onSubmit - ? formMethods.handleSubmit(async data => { + ? formMethods.handleSubmit(async (data, event) => { + const submitEvent = event?.nativeEvent as + | SubmitEvent + | undefined; + if (submitEvent === undefined) { + console.error( + "Can't handle submission without event" + ); + return; + } + const action = ( + submitEvent.submitter as HTMLButtonElement + )?.value; updatePrompt(data); console.log('Submitting form...'); - onSubmit(data); + onSubmit({ ...data, action }); }) : undefined }