0

I'm using a SurveyJs based survey in React with Zustand global state management and I'am communicating with an API. I wanted to add a 'Save for later' Button to the navigation buttons so the user can continue the survey later (saved in db). When clicked a Modal appears where the user can type in their email address. For some reason, when the button gets clicked and one of those global state functions get called the survey.data get's cleared out.

Here is the code of the custom navigation button:

survey.addNavigationItem({
id: "survey_continue_later",
title: "Continue later",
visibleIndex: 51, // "Complete" button has the visibleIndex 50.
action: () => {
  console.log("SAVE REQUESTED");
  setModalMode(false);
  //openModal();
},});

I double checked everything and nothing else interferes with the survey.data, the setModalMode() function only sets another state variable and based on that variable's boolean state the Modal has a different appearence. Also when the Modal gets closed with the closeModal() function elsewhere in the code, again the survey.data gets cleared out. I'm thinking that this is some sort of 'focus' related issue.

If you can help any way or have a better idea, well I'm thrilled to read it.

Thank you in advance!

0 Answers0