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.2k stars 809 forks source link

Dynamic Panel: Initial `panelCount` value is ignored #6005

Closed d3n13 closed 1 year ago

d3n13 commented 1 year ago

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

Bug report

What is the current behavior?

Initial panel count (panelCount property) is ignored for PanelDynamic questions and displays to 0 instead of a provided value when initializing survey creator:
image

What is the expected behavior?

Initial panel count control should pick up and display panelCount property for PanelDynamic questions correctly

How would you reproduce the current behavior (if this is a bug)?

  1. Click on question1 in the CodeSandbox example
  2. Scroll to the Initial panel count setting in the General section
  3. It shows 0 instead of 2, provided in the panelCount field

Provide the test code and the tested page URL (if applicable)

Tested page URL: https://codesandbox.io/s/reproduce-survey-creator-panel-count-reset-on-init-7bcivi?file=/src/App.tsx

Test code

import { SurveyCreatorComponent, SurveyCreator } from "survey-creator-react";
import "survey-core/defaultV2.min.css";
import "survey-creator-core/survey-creator-core.min.css";

const creator = new SurveyCreator();
creator.JSON = {
  logoPosition: "right",
  pages: [
    {
      name: "page1",
      elements: [
        {
          type: "paneldynamic",
          name: "question1",
          templateElements: [
            {
              type: "text",
              name: "question4"
            }
          ],
          panelCount: 2,
          minPanelCount: 1,
          maxPanelCount: 3
        }
      ]
    }
  ]
};

export default function App() {
  return <SurveyCreatorComponent creator={creator} />;
}

Specify your

JaneSjs commented 1 year ago

Hello @d3n13, Thank you for reporting this issue. We'll investigate it and get back to you shortly.