-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Description
Describe the bug
Cannot bind custom checkbox element's checked
value.
I am using the new FAST web components in a Blazor server side application and trying to bind the checkbox component any way I can, referencing <input type="checkbox" />
:
<!-- Works! -->
<input type="checkbox" @bind="MyBool" />
<!-- Does not work... -->
<fast-checkbox @bind-checked="MyBool" @bind-checked:event="onchange"></fast-checkbox>
<fast-checkbox checked="@MyBool" @onchange="@((ChangeEventArgs e) => ViewModel.AcceptTerms = (bool)e.Value"></fast-checkbox>
I know the values themselves are binding because changing the native input will cause the fast components to change to match. The problem seems to lie within the event. The event mapping code has a check built in specifically for checkboxes which causes the change event value to fall back to element.value
, in this case e.Value
is always "on"
.
Rather than making an exception for checkboxes, could we simply always include both value
and checked
in ChangeEventArgs
to match the JavaScript behavior? If this approach is acceptable I will open a PR.