We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 73dc942 commit 877afdfCopy full SHA for 877afdf
components/QuizForm.tsx
@@ -156,10 +156,15 @@ const QuizForm: FC<Props> = ({
156
};
157
158
const handleRadioCheckboxClick = (event: any, isItMulti: boolean = false) => {
159
- let finalData = [event.target.value];
+ const valueToManage = event.target.value;
160
+ let finalData = [valueToManage];
161
if (isItMulti) {
162
const savedData = checkedAnswers[currentQuestionIndex] || [];
- finalData = [...savedData, event.target.value];
163
+ if (savedData.includes(valueToManage)) {
164
+ finalData = savedData.filter((item) => item !== valueToManage);
165
+ } else {
166
+ finalData = [...savedData, valueToManage];
167
+ }
168
}
169
setCheckedAnswers((prev) => ({
170
...prev,
0 commit comments