dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.37k stars 9.99k forks source link

In Blazor Web App InteractiveWebAssembly, using select with onchange event does not work when clicking from dropdown, but work with up/down key from keyboard. #54732

Closed MegateriumX closed 6 months ago

MegateriumX commented 7 months ago

Is there an existing issue for this?

Describe the bug

When using <select>, onchange event doesn't work when clicking from dropdown but work when using up/down key from keyboard. This happens only in InteractiveWebAssembly.

@page "/test"
@rendermode InteractiveWebAssembly

<select @onchange="Test">
    <option value="1">1</option>
    <option value="2">2</option>
</select>

@code {
    private void Test()
    {
        // Does not get triggered when using mouse to click from dropdown, but using up/down key works.
    }
}

Expected Behavior

The onchange event get triggered when clicking from dropdown.

Steps To Reproduce

  1. Create new Blazor Web App in VS2022.
  2. Select Auto (Server and WebAssembly) in Interactive render mode during creating wizard.
  3. Select Per page/component in Interactivity location during creation wizard
  4. Add select to any page.
  5. Set page @rendermode to InteractiveWebAssembly
  6. Bind onchange event to <select>

Exceptions (if any)

No response

.NET Version

8.0.202

Anything else?

No response

MegateriumX commented 7 months ago

After some more testing, it seems that the event is actually triggered but the breakpoints is not getting hit when clicking the dropdown. The breakpoint only hit when using up/down keyboard key. I'm using Microsoft Edge to test the breakpoint. Not sure this is the browser problem or Blazor problem.