diff --git a/src/question_paneldynamic.ts b/src/question_paneldynamic.ts index f71baa6073..51b3c55ee2 100644 --- a/src/question_paneldynamic.ts +++ b/src/question_paneldynamic.ts @@ -938,7 +938,7 @@ export class QuestionPanelDynamicModel extends Question const panel = this.createNewPanel(); this.panelsCore.push(panel); if (this.renderMode == "list" && this.panelsState != "default") { - if (this.panelsState === "expand") { + if (this.panelsState === "expanded") { panel.expand(); } else { if (!!panel.title) { diff --git a/tests/question_paneldynamic_tests.ts b/tests/question_paneldynamic_tests.ts index 1188e048fb..9f4be4b459 100644 --- a/tests/question_paneldynamic_tests.ts +++ b/tests/question_paneldynamic_tests.ts @@ -7069,6 +7069,42 @@ QUnit.test("panel dynamic & panel visibleIf & checkbox vs carry forward, #7693", }); }); +QUnit.test("paneldynamic: panelsState & valueName Bug#8653", function (assert) { + const survey = new SurveyModel({ + elements: [ + { + "type": "checkbox", + "name": "state_names", + "title": "States", + "valuePropertyName": "state_name", + "choices": ["ACT", "NSW", "QLD"] + }, + { + "type": "paneldynamic", + "name": "regions", + "valueName": "state_names", + "allowAddPanel": false, + "allowRemovePanel": false, + "visibleIf": "{state_names} notempty", + "panelsState": "expanded", + "templateTitle": "Regions for State {panel.state_name}", + "templateElements": [ + { + "type": "text", + "name": "q1" + } + ] + } + ] + }); + const checkbox = survey.getQuestionByName("state_names"); + const panel = survey.getQuestionByName("regions"); + checkbox.selectAll(); + assert.equal(panel.visiblePanels.length, 3, "3 panels have been created"); + assert.equal(panel.visiblePanels[0].state, "expanded", "panels[0] state is expanded"); + assert.equal(panel.visiblePanels[1].state, "expanded", "panels[1] state is expanded"); + assert.equal(panel.visiblePanels[2].state, "expanded", "panels[2] state is expanded"); +}); QUnit.test("paneldynamic: check renderedPanels", function (assert) { const survey = new SurveyModel({ elements: [