File tree Expand file tree Collapse file tree 3 files changed +5
-2
lines changed
tools/work/work-self-service/intake-forms/bug-hunt Expand file tree Collapse file tree 3 files changed +5
-2
lines changed Original file line number Diff line number Diff 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 ( ( ) => {
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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' ,
You can’t perform that action at this time.
0 commit comments