-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Razor Components - onclick handler not called if href is set in <a> tag #9773
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
Comments
I believe this is the default behavior of opening a new page, and, since you've got no such url, the default behavior of the Blazor routing system is to navigate to the home page. Try to return false from your click event.
Hope this works... |
Unfortunately, it fails because it doesn't call the handler at all. This code will still result in the redirect:
|
According to this dotnet/blazor#937 pull request, .preventDefault() is no longer called when you click on a link.
It is something you will be able to do in 3.0.0-preview6 according to this #5545 issue. In the meantime, if it is possible in your situation, you can remove the |
Uh oh!
There was an error while loading. Please reload this page.
Describe the bug
Href attributes take precedence over click handlers in razor components for
<a>
tagsTo Reproduce
Steps to reproduce the behavior:
Pages/Counter.razor
file's buttonfrom
to
Expected behavior
Increment the counter as it did before
Additional context
Installed dotnet version:
dotnet 3.0.100-preview4-011223
The text was updated successfully, but these errors were encountered: