mirror of
https://github.com/formbricks/formbricks.git
synced 2026-03-20 17:31:27 -05:00
fix: Unsaved Changes Confirm even though changes were saved (#2372)
Co-authored-by: Johannes <72809645+jobenjada@users.noreply.github.com>
This commit is contained in:
@@ -53,7 +53,7 @@ export default function SurveyEditor({
|
||||
}: SurveyEditorProps): JSX.Element {
|
||||
const [activeView, setActiveView] = useState<TSurveyEditorTabs>("questions");
|
||||
const [activeQuestionId, setActiveQuestionId] = useState<string | null>(null);
|
||||
const [localSurvey, setLocalSurvey] = useState<TSurvey | null>(survey);
|
||||
const [localSurvey, setLocalSurvey] = useState<TSurvey | null>(() => structuredClone(survey));
|
||||
const [invalidQuestions, setInvalidQuestions] = useState<string[] | null>(null);
|
||||
const [selectedLanguageCode, setSelectedLanguageCode] = useState<string>("default");
|
||||
const surveyEditorRef = useRef(null);
|
||||
|
||||
@@ -118,6 +118,7 @@ export default function SurveyMenuBar({
|
||||
const handleBack = () => {
|
||||
const { updatedAt, ...localSurveyRest } = localSurvey;
|
||||
const { updatedAt: _, ...surveyRest } = survey;
|
||||
localSurveyRest.triggers = localSurveyRest.triggers.filter((trigger) => Boolean(trigger));
|
||||
|
||||
if (!isEqual(localSurveyRest, surveyRest)) {
|
||||
setConfirmDialogOpen(true);
|
||||
@@ -347,10 +348,12 @@ export default function SurveyMenuBar({
|
||||
return;
|
||||
}
|
||||
|
||||
strippedSurvey.triggers = strippedSurvey.triggers.filter((trigger) => Boolean(trigger));
|
||||
try {
|
||||
await updateSurveyAction({ ...strippedSurvey });
|
||||
|
||||
setIsSurveySaving(false);
|
||||
setLocalSurvey(strippedSurvey);
|
||||
toast.success("Changes saved.");
|
||||
if (shouldNavigateBack) {
|
||||
router.back();
|
||||
|
||||
Reference in New Issue
Block a user