Multi step form: make user selection required #780
-
It looks like our questions that are unique and their own components show a strange behaviour. When the user selects an option for the first question, the selection is saved in the state. If now the user clicks the remaining six questions without taking any option (he only clicks the "next"-button several times) it seems like for these six questions the state value of the first question is always used. The expected behaviour is that the state value of the remaining six questions is null (the state is initialized with null in the question component). PR follows. We are stuck here. Your help would be appreciated |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
Looking forward to your PR and then I will gladly take a look 👀 |
Beta Was this translation helpful? Give feedback.
-
Hi there, if you make the disabled attribute dependent on the The call of your <StyledButton
type="button"
disabled={selectedValue ? false : true}
onClick={() => {
handleNextButtonClick(questionData.topic, selectedValue);
setSelectedValue(null);
}}
>
next
</StyledButton> And for your onChange={(event) => setSelectedValue(Number(event.target.value))} The styling of the button looks somewhat counterintuitive, being blue while disabled and grey while enabled, but I am confident that you will find a solution! Hope this already helps, let me know otherwise ✌️ |
Beta Was this translation helpful? Give feedback.
-
Hi Nick, ty for the fast reply. We will refactor as you said. But I think it will not solve our problem. For example (Pete's sandbox)
|
Beta Was this translation helpful? Give feedback.
Hi there,
if you make the disabled attribute dependent on the
selectedValue
state, your form should work as intended.You can get rid of your
isChecked
state and of thehandleChange
function as well.The call of your
StyledButton
can look like this:And for your
StyledInput
you want to change theonChange
back to how it was this morning:The st…