Fix saved changes are not visible in Survey Editor (#674)

This commit is contained in:
Matti Nannt
2023-08-10 13:14:17 +02:00
committed by GitHub
parent 3bbb4170e2
commit 142c1bd35b
2 changed files with 4 additions and 5 deletions
@@ -29,11 +29,9 @@ export default function SurveyEditor({ environmentId, surveyId }: SurveyEditorPr
useEffect(() => {
if (survey) {
if (!localSurvey) {
setLocalSurvey(survey);
}
setLocalSurvey(survey);
if (!activeQuestionId && survey.questions.length > 0) {
if (survey.questions.length > 0) {
setActiveQuestionId(survey.questions[0].id);
}
}
@@ -65,7 +65,8 @@ export default function SurveyMenuBar({
// write a function which updates the local survey status
const updateLocalSurveyStatus = (status: Survey["status"]) => {
const updatedSurvey = { ...localSurvey, status };
const updatedSurvey = JSON.parse(JSON.stringify(localSurvey));
updatedSurvey.status = status;
setLocalSurvey(updatedSurvey);
};