The Select Tag Helper not select an empty value when the property is null
- 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
The Select Tag Helper not select an empty value when `Reason` is `null` for the following model:
```csharp
public sealed record DisableEmployee(string Name, [Required] EmployeeDisabledReason? Reason, DateTime EffectiveDate);
```
Definition of `EmployeeDisabledReason`:
```csharp
public enum EmployeeDisabledReason
{
Resigned = 0,
}
```
View:
```razor
Select a reason
```
Result HTML:
```html
Select a reason
Resigned
```
### Expected Behavior
I expect the first `option` that have the empty value have `selected` attribute applied. e.g.:
```html
Select a reason
Resigned
```
### Steps To Reproduce
_No response_
### Exceptions (if any)
_No response_
### .NET Version
6.0.102
### Anything else?
```
.NET SDK (reflecting any global.json):
Version: 6.0.102
Commit: 49861cb924
Runtime Environment:
OS Name: arch
OS Version:
OS Platform: Linux
RID: arch-x64
Base Path: /usr/share/dotnet/sdk/6.0.102/
Host (useful for support):
Version: 6.0.2
Commit: 839cdfb0ec
.NET SDKs installed:
6.0.102 [/usr/share/dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 3.1.20 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.2 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.20 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.2 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
To install additional .NET runtimes or SDKs:
https://aka.ms/dotnet-download
```
Contributor guide
Assessment
This issue has not been assessed yet.