Skip to content

Nested Dynamic Panel restores removed panels after value change when panelCount is set #10739

@danlevison

Description

@danlevison

Describe the bug
When using nested paneldynamic questions, removing all panels from the inner paneldynamic does not update panelCount. After a subsequent value change in the parent panel (e.g. selecting a radio button), the removed panels are automatically recreated, even though the user explicitly deleted them.

This appears to be a state reconciliation bug where panelCount is treated as authoritative and forces panel re-creation on value changes.

Steps to reproduce

  1. Load the following survey JSON:
{
 "pages": [
   {
     "name": "page1",
     "elements": [
       {
         "type": "paneldynamic",
         "name": "question1",
         "templateElements": [
           {
             "type": "radiogroup",
             "name": "question2",
             "isRequired": true,
             "choices": [
               "No",
               "Yes"
             ]
           },
           {
             "type": "paneldynamic",
             "name": "question3",
             "templateElements": [
               {
                 "type": "radiogroup",
                 "name": "question4",
                 "isRequired": true,
                 "choices": [
                   "No",
                   "Yes"
                 ]
               }
             ],
             "templateTitle": "{panelIndex}",
             "panelCount": 2,
             "panelsState": "collapsed"
           }
         ],
         "templateTitle": "{panelIndex}",
         "panelCount": 2,
         "panelsState": "collapsed"
       }
     ]
   }
 ],
 "headerView": "advanced"
}
  1. Open question1 → panel 1
  2. Open question3 → panel 1, then remove it
  3. Open question3 → panel 2, then remove it
  4. Select any option in question2
  5. Observe that two panels are recreated inside question3

Expected behavior

  • After removing panels from a nested paneldynamic:
  • The panels should remain removed
  • Subsequent value changes elsewhere should not recreate them
  • panelCount should reflect the actual number of panels, or at least not force re-creation

Screenshots
https://github.com/user-attachments/assets/c7d3fa22-ad2e-42b6-b34b-046b7ceb7611

Browser/SurveyJS Versions

  • Browser: Chrome
  • Browser version: 143.0.7499.169 (Official Build) (64-bit)
  • SurveyJS version: [e.g. v2.5.2]
  • Device: PC

Metadata

Metadata

Assignees

Labels

buguser issueAn issue or bug reported by users

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions