fix: Preview not showing correctly after changing the survey type (#852)

This commit is contained in:
Dhruwang Jariwala
2023-09-26 13:22:39 +05:30
committed by GitHub
parent 6c8d14409c
commit a3549cc92c
3 changed files with 3 additions and 4 deletions

View File

@@ -46,8 +46,8 @@ export default function SurveyEditor({
// when the survey type changes, we need to reset the active question id to the first question
useEffect(() => {
if (survey?.questions?.length > 0) {
setActiveQuestionId(survey.questions[0].id);
if (localSurvey && localSurvey.questions?.length > 0) {
setActiveQuestionId(localSurvey.questions[0].id);
}
}, [localSurvey?.type]);

View File

@@ -96,7 +96,6 @@ export default function WhenToSendCard({
setLocalSurvey(updatedSurvey);
};
useEffect(() => {
console.log(actionClassArray);
if (activeIndex !== null) {
setTriggerEvent(activeIndex, actionClassArray[actionClassArray.length - 1].id);
}

View File

@@ -22,7 +22,7 @@ export function Survey({
isRedirectDisabled = false,
prefillResponseData,
}: SurveyBaseProps) {
const [questionId, setQuestionId] = useState(activeQuestionId || survey.questions[0].id);
const [questionId, setQuestionId] = useState(activeQuestionId || survey.questions[0]?.id);
const [loadingElement, setLoadingElement] = useState(false);
const [history, setHistory] = useState<string[]>([]);
const [responseData, setResponseData] = useState<TResponseData>({});