-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
InputRadio component with form support #23415
Conversation
Open question: Should we ensure that the type of the value bound to Edit: I'm going to proceed under the assumption that we should, given |
InputChoice contains checks for valid choice types that used to exist in InputSelect. Both InputSelect and InputRadio now derive from InputChoice and thus also contain those checks.
src/Components/Web/ref/Microsoft.AspNetCore.Components.Web.netcoreapp.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great. @dotnet/aspnet-blazor-eng could you have a look please?
This is really great, @MackinnonBuck! Thanks for figuring out so many of the tricky details (e.g., around parsing) here and building it in a clean way. One suggestion around the API: I wonder if it might be possible to make this even more closely equivalent to <InputRadioGroup @bind-Value="mySelection">
<InputRadio Value="Colors.Red">A warm red</InputRadio>
<InputRadio Value="Colors.Green">An earthy green</InputRadio>
<InputRadio Value="Colors.Blue">A corporate blue</InputRadio>
</InputRadioGroup> With this, you no longer have to repeat Your scheme around an optional "name" looks like it's sufficient to support even the most unusual UI shapes alongside the requirement to declare a group explicitly, e.g. for this:
... developers could do: <InputRadioGroup Name="country" @bind-Value="selectedCountry">
<InputRadioGroup Name="color" @bind-Value="selectedColor">
<InputRadio Name="color" Value="red" />
<InputRadio Name="country" Value="japan" />
<InputRadio Name="color" Value="green" />
<InputRadio Name="country" Value="yemen" />
<InputRadio Name="color" Value="blue" />
<InputRadio Name="country" Value="latvia" />
<InputRadio Name="color" Value="orange" />
</InputRadioGroup>
</InputRadioGroup> BTW if the nested |
@SteveSandersonMS Thanks for the great suggestions! I have made those improvements and added tests for them. I had to introduce |
Is there a particular reason we ever limited what types could be bound when using
If I modify |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good :)
This is totally superb! Thanks for making the updates. I did have one further suggested tweak about where the validation CSS classes should show up - let me know what you think. Hopefully that would be a very small change, but if you think it's not the right design please say so. I'd say this is ready to merge once that last question is resolved. The test cases look great too.
Not as far as I know. It's quite possible that it's a historical artifact of what order we implemented things in. It's great you've found that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Brilliant, thanks for the final updates! This is a great feature.
Hi team, i've noticed that it's not possible to add an onchange event listener using InputRadio/InputRadioGroup. |
Hi @ehills. It looks like you just commented on a closed PR. The team will most probably miss it. If you'd like to bring something important up to their attention, consider filing a new issue and add enough details to build context. |
Summary:
InputRadio
component with form support.InputRadio
components interact withInputRadioGroup
components as expected.int
andGuid
binding support forInputRadio
andInputSelect
.Usage example:
If
Name
is omitted,InputRadio
components are grouped by their most recent ancestor.Addresses #5579, #9939 and #19562.