Skip to content

Commit d50324d

Browse files
committed
PROD-2644 #comment Fix unable to proceed to pay if user submits the contact support form
1 parent 866683d commit d50324d

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

src-ts/lib/form/form-functions/form.functions.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,14 @@ export async function onSubmitAsync<T>(
7272
): Promise<void> {
7373

7474
event.preventDefault()
75+
event.stopPropagation();
7576

7677
const { groups, shortName, successMessage }: FormDefinition = formDef
7778
const inputs: Array<FormInputModel> = getFormInputFields(groups || [])
7879

7980
// get the dirty fields before we validate b/c validation marks them dirty on submit
8081
const dirty: FormInputModel | undefined = inputs?.find(fieldDef => !!fieldDef.dirty)
81-
82+
const pristine: FormInputModel | undefined = inputs?.find(fieldDef => !!fieldDef.pristine)
8283
// if there are any validation errors, display a message and stop submitting
8384
// NOTE: need to check this before we check if the form is dirty bc you
8485
// could have a form that's not dirty but has errors and you wouldn't
@@ -98,7 +99,7 @@ export async function onSubmitAsync<T>(
9899
})
99100

100101
// if there are no dirty fields, don't actually perform the save
101-
const savePromise: Promise<void> = !dirty ? Promise.resolve() : save(formValue)
102+
const savePromise: Promise<void> = !dirty && !pristine ? Promise.resolve() : save(formValue)
102103

103104
return savePromise
104105
.then(() => {

src-ts/lib/form/form-input.model.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export interface FormInputModel {
2828
dirty?: boolean
2929
disabled?: boolean
3030
error?: string
31+
pristine?: boolean
3132
readonly events?: ReadonlyArray<InputEvent>
3233
readonly fileConfig?: {
3334
readonly acceptFileType?: string

src-ts/tools/work/work-self-service/intake-forms/bug-hunt/bug-hunt.form.config.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export const BugHuntFormConfig: FormDefinition = {
4141
{
4242
hideInlineErrors: true,
4343
label: 'Project title',
44+
pristine: true,
4445
name: ChallengeMetadataName.projectTitle,
4546
placeholder: 'Enter a descriptive title',
4647
type: 'text',

0 commit comments

Comments
 (0)