Skip to content

Commit

Permalink
Make sure we reset the formaction on the submit button
Browse files Browse the repository at this point in the history
  • Loading branch information
haacked committed Jan 2, 2024
1 parent 4d1e638 commit 7351f2b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,7 @@ export class ValidationService {
// Because the submitter is not propagated when calling
// form.submit(), we recreate it here.
const submitter = submitEvent.submitter;
let initialFormAction = form.action;
if (submitter) {
const name = submitter.getAttribute('name');
// If name is null, a submit button is not submitted.
Expand All @@ -814,6 +815,10 @@ export class ValidationService {
}

form.submit();

if (form.action != initialFormAction) {
form.action = initialFormAction;
}
}
}

Expand All @@ -830,7 +835,7 @@ export class ValidationService {
let invalidFormInputUIDs = formInputUIDs.filter(uid => this.summary[uid]);

if (invalidFormInputUIDs.length > 0) {
var firstInvalid = this.elementByUID[invalidFormInputUIDs[0]] as HTMLElement;
const firstInvalid = this.elementByUID[invalidFormInputUIDs[0]] as HTMLElement;
if (firstInvalid) {
firstInvalid.focus();
}
Expand Down

0 comments on commit 7351f2b

Please sign in to comment.