Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panel dynamic addConditionObjectsByContext function doesn't work correctly for a question in the nested panel dynamic #8186

Closed
andrewtelnov opened this issue Apr 25, 2024 · 0 comments · Fixed by #8187
Assignees
Labels
bug user issue An issue or bug reported by users
Milestone

Comments

@andrewtelnov
Copy link
Member

If there is a panel dynamic placed inside another dynamic panel then addConditionObjectsByContext doesn't work correctly.
The following unit test doens't work, tests objs[2] gives the error:

const survey = new SurveyModel({
    "elements": [
      {
        "type": "paneldynamic",
        "name": "question1",
        "title": "parent dynamic panel",
        "templateElements": [
          {
            "type": "paneldynamic",
            "name": "question2",
            "title": "nested dynamic panel",
            "templateElements": [
              {
                "type": "text",
                "name": "question3",
                "title": "nq1"
              },
              {
                "type": "text",
                "name": "question4",
                "title": "nq2"
              }
            ]
          },
          {
            "type": "text",
            "name": "question5",
            "title": "pq1"
          }
        ]
      }
    ]
  });
  const rootPanel = survey.getQuestionByName("question1");
  const nestedPanel = rootPanel.template.getQuestionByName("question2");
  const question3 = nestedPanel.template.getQuestionByName("question3");
  const objs: IConditionObject[] = [];
  rootPanel.addConditionObjectsByContext(objs, question3);
  assert.equal(objs.length, 4, "There should be 4 elements");
  assert.equal(objs[0].name, "question1[0].question2[0].question3", "value #0");
  assert.equal(objs[1].name, "question1[0].question2[0].question4", "value #1");
  assert.equal(objs[2].name, "panel.question4", "value #2");
  assert.equal(objs[2].text, "panel.nq2", "text #2");
  assert.equal(objs[3].name, "question1[0].question5", "value #3");
@andrewtelnov andrewtelnov added bug user issue An issue or bug reported by users labels Apr 25, 2024
@andrewtelnov andrewtelnov added this to the v1.10.2 milestone Apr 25, 2024
@andrewtelnov andrewtelnov self-assigned this Apr 25, 2024
@andrewtelnov andrewtelnov changed the title panel dynamic addConditionObjectsByContext function doesn't work correctly for a question in the nested panel dynamic Panel dynamic addConditionObjectsByContext function doesn't work correctly for a question in the nested panel dynamic Apr 25, 2024
andrewtelnov added a commit that referenced this issue Apr 25, 2024
…ectly for a question in the nested panel dynamic fix #8186
tsv2013 pushed a commit that referenced this issue Apr 26, 2024
…ectly for a question in the nested panel dynamic fix #8186 (#8187)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug user issue An issue or bug reported by users
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant