Skip to content

@bind:after is not firing when used with select in Blazor #11696

@imsam67

Description

@imsam67

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

The bind:after is not firing when used in a select in Blazor WASM (Standalone) targeting .NET 9. I understand this was an issue in .NET 7 and was later fixed. I wonder if this is a regression. You can either use the following code or download from public repo at https://github.com/imsam67/blazor-bind-after-issue

Please also note that I tried it .NET 8 and .NET 7. It seems to work only in .NET 7! When I targeted .NET 8, again, I was NOT able to hit the DoSomething() method which should've fired after selecting an option.

<div>
    <select @bind="SelectedState" @bind:after="DoSomething">
        <option value="">Please select one</option>
        <option value="AK">Alaska</option>
        <option value="MT">Montana</option>
        <option value="WY">Wyoming</option>
    </select>
</div>

@code {

    private string SelectedState;

    private async Task DoSomething()
    {
        var userSelected = SelectedState; // Have a break point here but the code doesn't hit it
    }
}

Expected Behavior

When an option is selected, the DoSomething() method should be called.

Steps To Reproduce

Create a Blazor WASM (Standalone) project targeting .NET 9 and use the above code in any page.

Exceptions (if any)

None

.NET Version

9.0.201

Anything else?

No

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions