fix: unformatted recall question in logic editor (#2126)

This commit is contained in:
Dhruwang Jariwala
2024-02-27 01:47:59 +05:30
committed by GitHub
parent a027d1ef3d
commit 60b474a4f9
2 changed files with 6 additions and 1 deletions

View File

@@ -4,6 +4,7 @@ import { useMemo } from "react";
import { toast } from "react-hot-toast";
import { BsArrowDown, BsArrowReturnRight } from "react-icons/bs";
import { checkForRecallInHeadline } from "@formbricks/lib/utils/recall";
import {
TSurvey,
TSurveyLogic,
@@ -44,6 +45,10 @@ export default function LogicEditor({
questionIdx,
updateQuestion,
}: LogicEditorProps): JSX.Element {
localSurvey = useMemo(() => {
return checkForRecallInHeadline(localSurvey);
}, [localSurvey]);
const questionValues = useMemo(() => {
if ("choices" in question) {
return question.choices.map((choice) => choice.label);

View File

@@ -102,7 +102,7 @@ export const checkForEmptyFallBackValue = (survey: TSurvey): TSurveyQuestion | n
// Processes each question in a survey to ensure headlines are formatted correctly for recall and return the modified survey.
export const checkForRecallInHeadline = (survey: TSurvey): TSurvey => {
const modifiedSurvey = { ...survey };
const modifiedSurvey = structuredClone(survey);
modifiedSurvey.questions.forEach((question) => {
question.headline = recallToHeadline(question.headline, modifiedSurvey, false);
});