Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Blazor] - Issue calling submitRequest on data-enhanced form #58244

Open
1 task done
Travis-Th opened this issue Oct 4, 2024 · 0 comments
Open
1 task done

[Blazor] - Issue calling submitRequest on data-enhanced form #58244

Travis-Th opened this issue Oct 4, 2024 · 0 comments
Labels
area-blazor Includes: Blazor, Razor Components investigate

Comments

@Travis-Th
Copy link

Travis-Th commented Oct 4, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Calling requestSubmit on a form with the data-enhance attribute prints an uncaught TypeError to the console. It complains about accessing a member on a null submitter.

Expected Behavior

I would expect the navigation to be enhanced, and for the form to post.

Steps To Reproduce

Put this form in an SSR page, and click the button. The error should be printed to console.

<form id="test-form" method="post" @formname="my-form-name" data-enhance>
    <AntiforgeryToken />
    <button type="button" onclick="document.getElementById('test-form').requestSubmit()">I print an uncaught TypeError to the console!</button>
</form>

Exceptions (if any)

No response

.NET Version

8.0.200

Anything else?

I think the issue is caused by this line not properly checking for null, but I could be mistaken. Not super familiar with how enhanced navigation works internally.

const submitterValue = event.submitter!.getAttribute('value');

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-blazor Includes: Blazor, Razor Components label Oct 4, 2024
@javiercn javiercn added this to the .NET 10 Planning milestone Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-blazor Includes: Blazor, Razor Components investigate
Projects
None yet
Development

No branches or pull requests

2 participants