Bug: Selector does not give back selected option on selection
-
Fix by adding a handler when Selector with a single choice has been selected. -
Make sure an object with the translated label value and the key is handed back both or a reference to its state
<Form
initFormState={{
translation: {
label: 'branche wählen',
options: [
'übersetzen, dolmetschen',
'texten, korrektur, lektorat',
'sprachunterricht',
'nachhilfeunterricht',
'medien & journalismus',
'online marketing & klassische werbung',
'coaching',
],
},
}}
handleFormSubmit={console.log}
handleFormChange={console.log}
>
<Selector name="translation"></Selector>
<button value="submit"></button>
</Form>
After selecting an option e.g. coaching,
console output looks like this:
{
"translation": {
"name": "translation",
"label": "branche wählen",
"options": [
"übersetzen, dolmetschen",
"texten, korrektur, lektorat",
"sprachunterricht",
"nachhilfeunterricht",
"medien & journalismus",
"online marketing & klassische werbung",
"coaching"
],
"isDropdownOpen": false,
"optionsSelected": [
0
],
"errors": false
}
}
instead of
"coaching"
or
{
target: {
value: "coaching"
/* id: "coaching" */
}
}