Context
The addPicker method allows you to pass values through to the hx.Picker using pickerOptions which includes the initial value. When the picker is not required in the form, the value is then set to the value of the first item in the list.
The intended code is as follows:
new hx.Form(hx.select('body').clear().append('form'))
.addPicker('Select', ['red', 'green', 'blue'], { pickerOptions: { value: 'blue' } })
Expected Behavior
The picker should have the value of blue
Actual Behavior
The picker uses the first value and has red
Possible Fix
- Update the point where the first value is set to detect if the value is already being set with
pickerOptions.value and use that instead.
Workaround
Passing required: true causes the picker to start with a value and not set the value inside the addPicker method, leaving the desired behaviour.
new hx.Form(hx.select('body').clear().append('form'))
.addPicker('Select', ['red', 'green', 'blue'], { pickerOptions: { value: 'blue' }, required: true })
Steps to Reproduce
new hx.Form(hx.select('body').clear().append('form'))
.addPicker('Select', ['red', 'green', 'blue'], { pickerOptions: { value: 'blue' } })
Your Environment
Context
The
addPickermethod allows you to pass values through to thehx.PickerusingpickerOptionswhich includes the initialvalue. When the picker is notrequiredin the form, the value is then set to the value of the first item in the list.The intended code is as follows:
Expected Behavior
The picker should have the value of
blueActual Behavior
The picker uses the first value and has
redPossible Fix
pickerOptions.valueand use that instead.Workaround
Passing
required: truecauses the picker to start with a value and not set thevalueinside theaddPickermethod, leaving the desired behaviour.Steps to Reproduce
Your Environment