-
Notifications
You must be signed in to change notification settings - Fork 10.3k
InputSelectEnum #34823
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Should |
I would think we'd stick to the currently established convention of aspnetcore/src/Components/Web/src/Forms/InputSelect.cs Lines 14 to 24 in 6eaba08
That's a good idea, and seems to be consistent with the behavior of |
Thanks for contacting us. |
@DamianEdwards mentioned something like this here #33950 (comment) |
@mkArtakMSFT any chance of Microsoft.AspNetCore.Components.Forms.InputExtensions getting moved from |
I personally think these kinds of things should be in the framework by default. Punting to the community every time there's an opportunity to provide clear "customer delight" for very common scenarios is misguided IMO. In this case I'd go further and wouldn't make it a discrete component but rather make |
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process. |
Thanks for contacting us. We're moving this issue to the |
While I see there are definitely cases where this would help, it does bias towards quick prototyping over cases where you're trying to make a well-polished result, because:
|
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process. |
Closing based on @SteveSandersonMS 's last response, given that we've received no further objections to that response. |
Uh oh!
There was an error while loading. Please reload this page.
Summary
A new Blazor form component that automatically lists enum values that an InputSelect can receive.
Motivation and goals
I often find myself writing this same
InputSelect
code over and over:A separate
InputSelectEnum<TValue>
component that removes this boilerplate could be useful, imo.I would write this privately for myself, copying the existing InputSelect code and tweaking it. The only changes from the existing code is a modification of the BuildRenderTree method to generate options instead of displaying child content.
However, certain pieces of the
InputSelect
code that I'd use as a baseline areinternal
, such as the InputExtensions.TryParseSelectableValueFromString method and InputBase.FieldIdentifier used for value binding and validation messages, respectively.In scope
select
with all possible enum valuesTValue
Func<TValue, string>
. When this parameter is absent, display usingSystem.CompnentModel.DataAnnotations.DisplayAttribute.Name
if available, thenToString()
Out of scope
Risks / unknowns
If we wish to support nullable enums, then using the generic constraint
where TValue : Enum
is not a valid path. Therefore, type validity will need to be enforced at runtime.Examples
An existing example of another developer implementing this component can be found here. That particular implementation may have been using the value binding code from this repo as it existed but it now differs from the code we find in main, and thus results in an inconsistent experience alongside the equivalent InputSelect.
The text was updated successfully, but these errors were encountered: