dotnet / dotnet/aspnetcore

Blazor WebAssembly - HTML select tag with @onchange event does not hit breakpoint when clicking to select values from dropdown using the cursor, but works with up/down key from keyboard

Open
#60,018 9 comments 2 reactions 0 assignees View on GitHub
area-blazor
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

### Is there an existing issue for this?

- [x] I have searched the existing issues

### Describe the bug

In .NET8 and .NET9, in a new Blazor WebAssembly app, when using a `` tag, with the `@onchange` event, if I put a breakpoint in the method being triggered (i.e. `@onchange="Test"`), the breakpoint will not be hit if I click on different values in the dropdown using the mouse.
However, the breakpoint is being hit fine when using the up/down keys from the keyboard.

`` works `@onchange` event, but `` no

In addition, when using the mouse, I can see that the method is run and states are changed - the issue I experienced is the breakpoint that is not being hit.

Additional info: doing the same in .NET6 works fine, and breakpoint is being hit just fine in all cases.

```
@page "/"
Countries

USA>
Canada
Mexico

@code {

private void OnCountryChanged(ChangeEventArgs e)
{
}

}
```

reference: dotnet/aspnetcore#58615

### Expected Behavior

Breakpoint is being hit when using the mouse/cursor to select different values from a select statement with the `@onchange` event

### Steps To Reproduce

Create a new Blazor Web Assembly (WASM) project in VS2022.
Add a select tag to any page (I did it to the Counter component)
add the `@onchange` event to the select tag, and assign it with a method
Put a breakpoint in the method assigned to the `@onchange` event
Run the app, click on different values in the dropdown, and see that the breakpoint is not being hit.
Then, try selecting using different values using the up/down keys from the keyboard, and the breakpoint should be hit

### Exceptions (if any)

_No response_

### .NET Version

_No response_

### 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.