Skip to content

Commit

Permalink
[Blazor] - Issue calling submitRequest on data-enhanced form
Browse files Browse the repository at this point in the history
Co-authored-by: Adit Sheth <[email protected]>

Fixes #58244

This PR fixes an issue where calling requestSubmit on a form with the data-enhance attribute caused an uncaught TypeError due to accessing a member on a null event.submitter.

The change replaces the non-null assertion operator (!) with the optional chaining operator (?) to properly handle cases where event.submitter is null.
  • Loading branch information
shethaadit authored Dec 13, 2024
1 parent a122a40 commit 5a42e1e
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ function onDocumentSubmit(event: SubmitEvent) {
const formData = new FormData(formElem);

const submitterName = event.submitter?.getAttribute('name');
const submitterValue = event.submitter!.getAttribute('value');
const submitterValue = event.submitter?.getAttribute('value');
if (submitterName && submitterValue) {
formData.append(submitterName, submitterValue);
}
Expand Down

0 comments on commit 5a42e1e

Please sign in to comment.