dotnet / dotnet/aspnetcore

[Blazor] preventDefault does not function in Auto render mode, even if the page is marked with InteractiveWebAssembly

Open
#52,514 10 comments 5 reactions 0 assignees View on GitHub
area-blazor bug Pillar: Complete Blazor Web
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Describe the bug

`Click me`

it is not preventing the default handling in a Blazor App with Auto interactivity, even if the page is properly configured for WebAssembly. If the App is created only with WebAssembly interactivity, it works as expected.

#50992 is similar, but it does not indicate any resolution.

### Expected Behavior

preventDefault should prevent any further navigation

### Steps To Reproduce

- Create a Blazor App with Auto interactivity
- In the Counter.razor page from the Blazor WebApp template, replace the button markup with: `Click me`
- Even if the page is marked with `@rendermode InteractiveAuto` or `@rendermode InteractiveWebAssembly`, clicking on the link triggers the default navigation to home. preventDefault should have stopped this.

### Exceptions (if any)

If the Blazor App is created only with WebAssembly interactivity, it works as expected.

### .NET Version

8.0.100

### Anything else?

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.