mirror of
https://github.com/formbricks/formbricks.git
synced 2025-12-30 10:19:51 -06:00
fix: multi select question (#5792)
Co-authored-by: pandeymangg <anshuman.pandey9999@gmail.com>
This commit is contained in:
committed by
GitHub
parent
6442b5e4aa
commit
34bb9c2127
@@ -121,6 +121,16 @@ export function MultipleChoiceMultiQuestion({
|
||||
onChange({ [question.id]: [] }); // if not array, make it an array
|
||||
};
|
||||
|
||||
const getIsRequired = () => {
|
||||
const responseValues = [...value];
|
||||
if (otherSelected && otherValue) {
|
||||
responseValues.push(otherValue);
|
||||
}
|
||||
return question.required && Array.isArray(responseValues) && responseValues.length
|
||||
? false
|
||||
: question.required;
|
||||
};
|
||||
|
||||
return (
|
||||
<form
|
||||
key={question.id}
|
||||
@@ -195,7 +205,7 @@ export function MultipleChoiceMultiQuestion({
|
||||
Array.isArray(value) &&
|
||||
value.includes(getLocalizedValue(choice.label, languageCode))
|
||||
}
|
||||
required={otherSelected && otherValue ? false : question.required}
|
||||
required={getIsRequired()}
|
||||
/>
|
||||
<span id={`${choice.id}-label`} className="fb-ml-3 fb-mr-3 fb-grow fb-font-medium">
|
||||
{getLocalizedValue(choice.label, languageCode)}
|
||||
|
||||
Reference in New Issue
Block a user