You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
dot:ComboBox, and probably any other controls that derive from Selector, do not support (nullable) boolean properties. Selecting the option with the value null behaves as expected, but selecting and other option will always set the value to true.
Using DotVVM.AspNetCore version 4.2.6 on net6.0.
Example code:
<divclass="form-group" Validator.InvalidCssClass="has-error" Validator.Value="{value: Form.HasGenerator}"><labelfor="HasGenerator">Is there a generator? <spanclass="text-danger">*</span></label><dot:ComboBoxhtml:id="HasGenerator" SelectedValue="{value: Form.HasGenerator}" class="form-control"><dot:SelectorItemText="Choose an option..." Value="{value: null}" />
<dot:SelectorItemText="No" Value="{value: false}" />
<dot:SelectorItemText="Yes" Value="{value: true}" />
</dot:ComboBox></div>
When Choose an option... is selected, dotvvm.viewModels.root.viewModel.Form.state.HasGenerator evaluates to null. When any other option (Yes or No) is selected, dotvvm.viewModels.root.viewModel.Form.state.HasGenerator evaluates to true.
(I am using ComboBox instead of RadioButtons for accessibility reasons on mobile.)
The text was updated successfully, but these errors were encountered:
* broken JS coercion from 'false' to boolean fixed
* SelectorItems renders all non-string values as `data-bind='value: value'`.
Knockout.js then reads the value binding instead of the value attribute, so
we avoid the roundtrip through strings
resolves#1812
exyi
linked a pull request
May 7, 2024
that will
close
this issue
Thanks for the bug report. While fixing this, I found that it works when you bind the booleans through DataSource instead of the hardcoded SelectorItems. I think that you can use that as a workaround before we release the fix
dot:ComboBox
, and probably any other controls that derive fromSelector
, do not support (nullable) boolean properties. Selecting the option with the valuenull
behaves as expected, but selecting and other option will always set the value totrue
.Using
DotVVM.AspNetCore
version 4.2.6 onnet6.0
.Example code:
When
Choose an option...
is selected,dotvvm.viewModels.root.viewModel.Form.state.HasGenerator
evaluates tonull
. When any other option (Yes
orNo
) is selected,dotvvm.viewModels.root.viewModel.Form.state.HasGenerator
evaluates totrue
.(I am using
ComboBox
instead ofRadioButton
s for accessibility reasons on mobile.)The text was updated successfully, but these errors were encountered: