diff --git a/apps/docs/components/icons/TwitterIcon.tsx b/apps/docs/components/icons/TwitterIcon.tsx index af8277f2dc..2117e44d83 100644 --- a/apps/docs/components/icons/TwitterIcon.tsx +++ b/apps/docs/components/icons/TwitterIcon.tsx @@ -9,7 +9,7 @@ export const TwitterIcon: React.FC> = (props) => { width="1em" xmlns="http://www.w3.org/2000/svg" {...props}> - + ); }; diff --git a/apps/web/app/(app)/(survey-editor)/environments/[environmentId]/surveys/[surveyId]/edit/components/QuestionCard.tsx b/apps/web/app/(app)/(survey-editor)/environments/[environmentId]/surveys/[surveyId]/edit/components/QuestionCard.tsx index bb59974804..5435bd7774 100644 --- a/apps/web/app/(app)/(survey-editor)/environments/[environmentId]/surveys/[surveyId]/edit/components/QuestionCard.tsx +++ b/apps/web/app/(app)/(survey-editor)/environments/[environmentId]/surveys/[surveyId]/edit/components/QuestionCard.tsx @@ -86,11 +86,16 @@ export const QuestionCard = ({ const open = activeQuestionId === question.id; const [openAdvanced, setOpenAdvanced] = useState(question.logic && question.logic.length > 0); - const updateEmptyNextButtonLabels = (labelValue: TI18nString) => { + const updateEmptyButtonLabels = ( + labelKey: "buttonLabel" | "backButtonLabel", + labelValue: TI18nString, + skipIndex: number + ) => { localSurvey.questions.forEach((q, index) => { - if (index === localSurvey.questions.length - 1) return; - if (!q.buttonLabel || q.buttonLabel[selectedLanguageCode]?.trim() === "") { - updateQuestion(index, { buttonLabel: labelValue }); + if (index === skipIndex) return; + const currentLabel = q[labelKey]; + if (!currentLabel || currentLabel[selectedLanguageCode]?.trim() === "") { + updateQuestion(index, { [labelKey]: labelValue }); } }); }; @@ -444,7 +449,11 @@ export const QuestionCard = ({ }; if (questionIdx === localSurvey.questions.length - 1) return; - updateEmptyNextButtonLabels(translatedNextButtonLabel); + updateEmptyButtonLabels( + "buttonLabel", + translatedNextButtonLabel, + localSurvey.questions.length - 1 + ); }} attributeClasses={attributeClasses} /> @@ -463,6 +472,14 @@ export const QuestionCard = ({ selectedLanguageCode={selectedLanguageCode} setSelectedLanguageCode={setSelectedLanguageCode} attributeClasses={attributeClasses} + onBlur={(e) => { + if (!question.backButtonLabel) return; + let translatedBackButtonLabel = { + ...question.backButtonLabel, + [selectedLanguageCode]: e.target.value, + }; + updateEmptyButtonLabels("backButtonLabel", translatedBackButtonLabel, 0); + }} /> )} diff --git a/apps/web/app/(app)/(survey-editor)/environments/[environmentId]/surveys/[surveyId]/edit/components/QuestionsView.tsx b/apps/web/app/(app)/(survey-editor)/environments/[environmentId]/surveys/[surveyId]/edit/components/QuestionsView.tsx index f402d813b1..bb809611fe 100644 --- a/apps/web/app/(app)/(survey-editor)/environments/[environmentId]/surveys/[surveyId]/edit/components/QuestionsView.tsx +++ b/apps/web/app/(app)/(survey-editor)/environments/[environmentId]/surveys/[surveyId]/edit/components/QuestionsView.tsx @@ -13,7 +13,7 @@ import { } from "@dnd-kit/core"; import { SortableContext, verticalListSortingStrategy } from "@dnd-kit/sortable"; import { createId } from "@paralleldrive/cuid2"; -import React, { SetStateAction, useEffect, useMemo, useState } from "react"; +import React, { SetStateAction, useEffect, useMemo } from "react"; import toast from "react-hot-toast"; import { MultiLanguageCard } from "@formbricks/ee/multi-language/components/multi-language-card"; import { addMultiLanguageLabels, extractLanguageCodes } from "@formbricks/lib/i18n/utils"; @@ -86,7 +86,6 @@ export const QuestionsView = ({ }, [localSurvey.questions]); const surveyLanguages = localSurvey.languages; - const [backButtonLabel, setbackButtonLabel] = useState(null); const handleQuestionLogicChange = (survey: TSurvey, compareId: string, updatedId: string): TSurvey => { const updateConditions = (conditions: TConditionGroup): TConditionGroup => { @@ -238,22 +237,6 @@ export const QuestionsView = ({ ...updatedAttributes, }; - if ("backButtonLabel" in updatedAttributes) { - const backButtonLabel = updatedSurvey.questions[questionIdx].backButtonLabel; - // If the value of backbuttonLabel is equal to {default:""}, then delete backButtonLabel key - if ( - backButtonLabel && - Object.keys(backButtonLabel).length === 1 && - backButtonLabel["default"].trim() === "" - ) { - delete updatedSurvey.questions[questionIdx].backButtonLabel; - } else { - updatedSurvey.questions.forEach((question) => { - question.backButtonLabel = updatedAttributes.backButtonLabel; - }); - setbackButtonLabel(updatedAttributes.backButtonLabel); - } - } const attributesToCheck = ["buttonLabel", "upperLabel", "lowerLabel"]; // If the value of buttonLabel, lowerLabel or upperLabel is equal to {default:""}, then delete buttonLabel key @@ -332,9 +315,6 @@ export const QuestionsView = ({ const addQuestion = (question: TSurveyQuestion, index?: number) => { const updatedSurvey = { ...localSurvey }; - if (backButtonLabel) { - question.backButtonLabel = backButtonLabel; - } const languageSymbols = extractLanguageCodes(localSurvey.languages); const updatedQuestion = addMultiLanguageLabels(question, languageSymbols); diff --git a/apps/web/app/(app)/environments/[environmentId]/settings/(account)/profile/components/EnableTwoFactorModal.tsx b/apps/web/app/(app)/environments/[environmentId]/settings/(account)/profile/components/EnableTwoFactorModal.tsx index fb30234833..ec26918830 100644 --- a/apps/web/app/(app)/environments/[environmentId]/settings/(account)/profile/components/EnableTwoFactorModal.tsx +++ b/apps/web/app/(app)/environments/[environmentId]/settings/(account)/profile/components/EnableTwoFactorModal.tsx @@ -163,7 +163,7 @@ const EnterCode = ({ setCurrentStep, setOpen, refreshData }: TEnableCodeProps) = // refresh data to update the UI refreshData(); - }else{ + } else { toast.error("The 2FA OTP is incorrect. Please try again."); } } catch (err) {