From f71cc87b3dd2c578bda78384ed5b0a2ca59910e5 Mon Sep 17 00:00:00 2001 From: moritzrengert Date: Tue, 30 May 2023 08:50:39 +0200 Subject: [PATCH] fix: update goToNextQuestion logic to work in last question --- .../environments/[environmentId]/surveys/PreviewSurvey.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/apps/web/app/environments/[environmentId]/surveys/PreviewSurvey.tsx b/apps/web/app/environments/[environmentId]/surveys/PreviewSurvey.tsx index 5af3c8666e..8d7bc0df23 100644 --- a/apps/web/app/environments/[environmentId]/surveys/PreviewSurvey.tsx +++ b/apps/web/app/environments/[environmentId]/surveys/PreviewSurvey.tsx @@ -191,16 +191,15 @@ export default function PreviewSurvey({ } } } - return questions[currentQuestionIndex + 1]?.id || ""; + return questions[currentQuestionIndex + 1]?.id || "end"; } const gotoNextQuestion = (data) => { const currentIndex = questions.findIndex((q) => q.id === activeQuestionId); const nextQuestionId = getNextQuestion(data); - if (currentIndex < questions.length - 1 && nextQuestionId !== "end") { + if (currentIndex < questions.length - 1 || nextQuestionId !== "end") { setActiveQuestionId(nextQuestionId); - // setActiveQuestionId(questions[currentIndex + 1].id); } else { if (thankYouCard?.enabled) { setActiveQuestionId("thank-you-card");