surveyjs / survey-library

Free JavaScript form builder library with integration for React, Angular, Vue, jQuery, and Knockout.
https://surveyjs.io/form-library
MIT License
4.11k stars 801 forks source link

("ClearInvisibleValues":"onHiddenContainer") Survey data is not removed when questions are hidden. This happens in Survey-jQuery version 1.9.67. #5474

Closed NicolasKolumbic closed 3 months ago

NicolasKolumbic commented 1 year ago

Are you requesting a feature, reporting a bug or asking a question?

I am reporting a bug, I see the problem carried over from "Survey-jquery 1.9.65".

What is the current behavior?

When trying to submit a form, I notice that it keeps the fields that were previously filled in, but were later hidden.

What is the expected behavior?

You should remove those values from "survey.data" when the fields are hidden by "visibleIf".

Specify your

JaneSjs commented 1 year ago

Hello @NicolasKolumbic, I created an example and confirmed that survey results (survey.data) doesn't contain a Boolean value, which is located on a hidden panel. Please check my results below.

Survey JSON:

export const json = {
  logoPosition: "right",
  pages: [
    {
      name: "page1",
      elements: [
        {
          type: "boolean",
          name: "pnlVisibilityFlag",
          title: "Hide Panel",
          defaultValue: "false"
        },
        {
          type: "panel",
          name: "panel1",
          elements: [
            {
              type: "boolean",
              name: "question1",
              defaultValue: "true"
            }
          ],
          visibleIf: "{pnlVisibilityFlag} = false"
        },
        {
          type: "text",
          name: "question2",
          defaultValue: "Test"
        }
      ]
    }
  ],
  clearInvisibleValues: "onHiddenContainer"
};

Example

Test Results:

Survey results contain three question answers:

{"pnlVisibilityFlag":false,"question2":"Test","question1":true}

Survey results contain two answers:

{"pnlVisibilityFlag":true,"question2":"Test"}

Would you please share a problematic survey JSON / example for investigation?