MudSelect should support nullable enums and show placeholder when value is null
#5,647 建立於 2022年11月3日
倉庫指標
- 星標
- (10,394 顆星)
- PR 合併指標
- (平均合併 6天 6小時) (30 天內合併 108 個 PR)
描述
Feature request type
Enhance component
Component name
MudSelect
Is your feature request related to a problem?
Our application has quite a number of enums associated with DTO properties.
When we bind these to form select components, traditionally empty items are now defaulted to the 1st item in the enumeration.
I can work around the issue by abstracting the select in a component that uses a list of strings; but it would be nice to not have a requirement to translate "some enum into strings" then back into "some enum value" because that's a lot of opportunity for us to create a translation bug. Or worse, have the 1st optional value saved when the customer didn't explicitly set an optional value.
Describe the solution you'd like
It would be nice if the select component could handle a nullable type. Or at the very least not select the 1st option when the bound property value doesn't match any of the options.
An example of the desired implementation for our enum types:
https://try.mudblazor.com/snippet/mkccbPOdotjpgVIT
The desired behavior, because the DTO property is "empty", would be that it shows the label instead of the 1st option:

Have you seen this feature anywhere else?
No response
Describe alternatives you've considered
No response
Pull Request
- I would like to do a Pull Request
Code of Conduct
- I agree to follow this project's Code of Conduct