From 9e91e572ba3d52f539c7abd86d1ffbae8088b505 Mon Sep 17 00:00:00 2001 From: Shubham Palriwala Date: Mon, 2 Oct 2023 13:07:33 +0530 Subject: [PATCH] fix: unable to add a new action while editing a survey (#899) --- .../[surveyId]/edit/WhenToSendCard.tsx | 86 ++++++++++--------- 1 file changed, 47 insertions(+), 39 deletions(-) diff --git a/apps/web/app/(app)/environments/[environmentId]/surveys/[surveyId]/edit/WhenToSendCard.tsx b/apps/web/app/(app)/environments/[environmentId]/surveys/[surveyId]/edit/WhenToSendCard.tsx index b9e9be88ac..6db7a9c3f7 100644 --- a/apps/web/app/(app)/environments/[environmentId]/surveys/[surveyId]/edit/WhenToSendCard.tsx +++ b/apps/web/app/(app)/environments/[environmentId]/surveys/[surveyId]/edit/WhenToSendCard.tsx @@ -104,7 +104,14 @@ export default function WhenToSendCard({ useEffect(() => { if (activeIndex !== null) { - setTriggerEvent(activeIndex, actionClassArray[actionClassArray.length - 1].id); + const newActionClassId = actionClassArray[actionClassArray.length - 1].id; + const currentActionClassId = localSurvey.triggers[activeIndex]?.id; + + if (newActionClassId !== currentActionClassId) { + setTriggerEvent(activeIndex, newActionClassId); + } + + setActiveIndex(null); } }, [actionClassArray, activeIndex, setTriggerEvent]); @@ -173,45 +180,46 @@ export default function WhenToSendCard({
- {localSurvey.triggers?.map((triggerEventClass, idx) => ( -
-
-

{idx === 0 ? "When" : "or"}

- -

action is performed

- + {!isAddEventModalOpen && + localSurvey.triggers?.map((triggerEventClass, idx) => ( +
+
+

{idx === 0 ? "When" : "or"}

+ +

action is performed

+ +
-
- ))} + ))}