Skip to content

Commit d5a0a3b

Browse files
authored
fix: adjust keys in choice qns so that qns with same choices work (ohcnetwork#11967)
1 parent 3e57382 commit d5a0a3b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/components/Questionnaire/QuestionTypes/ChoiceQuestion.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export const ChoiceQuestion = memo(function ChoiceQuestion({
103103
<SelectContent className="max-w-[var(--radix-select-trigger-width)] w-full">
104104
{options.map((option: AnswerOption) => (
105105
<SelectItem
106-
key={option.value.toString()}
106+
key={`${question.id}-${option.value.toString()}`}
107107
value={option.value.toString()}
108108
className="whitespace-normal break-words py-3"
109109
>
@@ -121,9 +121,9 @@ export const ChoiceQuestion = memo(function ChoiceQuestion({
121121
>
122122
{options.map((option: AnswerOption) => (
123123
<Label
124-
htmlFor={option.value.toString()}
124+
htmlFor={`${question.id}-${option.value.toString()}`}
125125
className="cursor-pointer"
126-
key={option.value.toString()}
126+
key={`${question.id}-${option.value.toString()}`}
127127
>
128128
<Card
129129
className="shadow-none rounded-md border-1 border-gray-400 bg-gray-200 p-2 transition-all hover:bg-gray-50/90 [&:has([data-state=checked])]:border-primary [&:has([data-state=checked])]:bg-primary-300 [&:has([data-state=checked])]:shadow-sm w-full"
@@ -132,7 +132,7 @@ export const ChoiceQuestion = memo(function ChoiceQuestion({
132132
<div className="flex flex-row items-center gap-2">
133133
<RadioGroupItem
134134
value={option.value.toString()}
135-
id={option.value.toString()}
135+
id={`${question.id}-${option.value.toString()}`}
136136
className="sr-only"
137137
/>
138138
<div className="font-medium leading-5">

0 commit comments

Comments
 (0)