Skip to content
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

RadioInput uses wrong attribute #1015

Closed
ffried opened this issue Jan 29, 2025 · 2 comments · Fixed by #1016
Closed

RadioInput uses wrong attribute #1015

ffried opened this issue Jan 29, 2025 · 2 comments · Fixed by #1016
Assignees
Labels
area-radio-input bug Something isn't working
Milestone

Comments

@ffried
Copy link

ffried commented Jan 29, 2025

Describe the bug
<RadioInput> does not work because it uses value attribute instead of checked.

To Reproduce
Steps to reproduce the behavior:

  1. Create a component that contains a RadioInput that is bound to a bool property (that is set to true)
  2. Show Component
  3. Radio input is not checked

Expected behavior
The radio input's checked state can be bound to a bool value

Versions (please complete the following information):

  • .NET Version: .NET 9
  • BlazorBootstrap: 3.3.0
  • Blazor WebAssembly / Server: WebAssembly
  • Blazor Interactive Render Mode: WebAssembly
  • Blazor Interactivity Location: n/a

Sample code

<RadioInput @bind-Value="IsOn1" Name="my-group"></RadioInput>
<RadioInput @bind-Value="IsOn2" Name="my-group"></RadioInput>

@code 
{
    private bool IsOn1 { get; set; } = true;
    private bool IsOn2 { get; set; }
}

Additional context
The built-in InputRadio uses a surrounding InputRadioGroup and then allows picking from a list of values. While I like the idea of having "standalone" radio buttons as well (like RadioInput), having a selection of some kind is currently also hard to do.
Similar problems go for CheckboxInput where the value is not a bool.

As a workaround, you can add checked=@myProperty to the RadioInput to at least get the rendering right. It still doesn't trigger the setter of other radio inputs in the group, though. So cleanup of other items in the group on the model side has to be done manually.

@gvreddy04 gvreddy04 added bug Something isn't working area-radio-input labels Jan 30, 2025
@gvreddy04 gvreddy04 self-assigned this Jan 30, 2025
@gvreddy04 gvreddy04 added this to the 3.3.1 milestone Jan 30, 2025
@gvreddy04
Copy link
Contributor

@ffried Thank you for reporting this.

gvreddy04 added a commit that referenced this issue Jan 30, 2025
gvreddy04 added a commit that referenced this issue Jan 30, 2025
* RadioInput uses wrong attribute #1015
@gvreddy04 gvreddy04 linked a pull request Jan 30, 2025 that will close this issue
@ffried
Copy link
Author

ffried commented Jan 30, 2025

@gvreddy04 Thanks for taking this on so quickly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-radio-input bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants