Consider changing the behavior of text inputs in Blazor to treat empty string as 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
### Is your feature request related to a problem? Please describe the problem.
Currently if the developer defines a text property as nullable (optional/not required) and the user touches the text input this triggers the validation and the user cannot remove the value. It is also impossible to remove the value in edit scenarios. This means that the developer must provide custom code to change every value from empty string to null. This is especially problematic when there is a min length validation.
### Describe the solution you'd like
Consider changing the behavior of text inputs in Blazor to automatically convert empty strings to null
While this suggestion is a breaking change I feel like it will be beneficial because it is hard to imagine many people want the empty string behavior. I also believe that ASP.NET MVC textboxes treat empty strings as null so there will be some consistency. Alternatively there might be a switch somewhere to turn on the null behavior. Another alternative is to provide another control with the new behavior. While creating such a control is not hard it will be good to not have to write it for every project.
### Additional context
This issue has been raised before but closed without consideration - https://github.com/dotnet/aspnetcore/issues/40785
Contributor guide
Assessment
This issue has not been assessed yet.