Blazor InputSelect sets wrong selected Option
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 276
Description
### Is there an existing issue for this?
- [X] I have searched the existing issues
### Describe the bug
Let's say that we have a really simple class with 2 properties, one is an integer and the other one is a string. I want to use EditForm with 2 InputSelect elements that are bind to these properties. The code looks like this:
```razor
@page "/test"
@using Microsoft.AspNetCore.Components
@using Newtonsoft.Json
Test
Test form
String
A
B
C
Integer
1
2
3
Start
@code {
readonly Dummy _dummy = new();
private void TestAsync()
{
Console.WriteLine("Object state: " + JsonConvert.SerializeObject(_dummy));
}
class Dummy
{
public string? StringProp { get; set; }
public int IntProp { get; set; }
}
}
```
Here is how it looks like in a web browser:

As we can see, if property is nullable, then Blazor will set the first option as selected. When we submit this form, the actual value of that property will not be the value of the selected option, it will be null.
### Expected Behavior
When we bind InputSelect to nullable property, it should not select any option by default. The behavior should be the same as with non-nullable properties
### Steps To Reproduce
_No response_
### Exceptions (if any)
_No response_
### .NET Version
6.0
### Anything else?
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.