Skip to content

Commit

Permalink
Feature : Toggle Multi-Select and Single-Select Question Types
Browse files Browse the repository at this point in the history
Feature : Toggle Multi-Select and Single-Select Question Types
  • Loading branch information
jobenjada committed Aug 5, 2023
2 parents ad42f4c + de3d580 commit 5c9605f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,15 @@ export default function MultipleChoiceMultiForm({
Add "Other"
</Button>
)}
<Button
size="sm"
variant="minimal"
type="button"
onClick={() => {
updateQuestion(questionIdx, { type: "multipleChoiceSingle" });
}}>
Convert to Single Select
</Button>

<div className="flex flex-1 items-center justify-end gap-2">
<Select
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,15 @@ export default function MultipleChoiceSingleForm({
Add &quot;Other&quot;
</Button>
)}
<Button
size="sm"
variant="minimal"
type="button"
onClick={() => {
updateQuestion(questionIdx, { type: "multipleChoiceMulti" });
}}>
Convert to Multi Select
</Button>

<div className="flex flex-1 items-center justify-end gap-2">
<Select
Expand Down
4 changes: 3 additions & 1 deletion apps/web/components/preview/MultipleChoiceMultiQuestion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ export default function MultipleChoiceMultiQuestion({
.map((choice) => choice.label);

useEffect(() => {
const nonOtherSavedChoices = storedResponseValue?.filter((answer) =>
if(Array.isArray(storedResponseValue)){
const nonOtherSavedChoices = storedResponseValue?.filter((answer) =>
nonOtherChoiceLabels.includes(answer)
);
const savedOtherSpecified = storedResponseValue?.find((answer) => !nonOtherChoiceLabels.includes(answer));
Expand All @@ -50,6 +51,7 @@ export default function MultipleChoiceMultiQuestion({
setOtherSpecified(savedOtherSpecified);
setShowOther(true);
}
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [storedResponseValue, question.id]);

Expand Down

2 comments on commit 5c9605f

@vercel
Copy link

@vercel vercel bot commented on 5c9605f Aug 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 5c9605f Aug 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

formbricks-com – ./apps/formbricks-com

formbricks-com.vercel.app
formbricks.com
formbricks-com-git-main-formbricks.vercel.app
formbricks-com-formbricks.vercel.app
www.formbricks.com

Please sign in to comment.