Skip to content

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

Open
@Marques01

Description

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

In .NET8 and .NET9, in a new Blazor WebAssembly app, when using a <select> 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.

<input> works @onchange event, but <select> 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 "/"
<label class="form-label">Countries</label>
<select class="form-select" @onchange="OnCountryChanged">
    <option value="1">USA></option>
    <option value="2">Canada</option>
    <option value="3">Mexico</option>
</select>
@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

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions