Skip to content

fix: resolve paneldynamic self-referential binding bug#195

Open
ihsankahveci wants to merge 1 commit intokc-pit-2026-testfrom
fix/non-family-network-binding-bug
Open

fix: resolve paneldynamic self-referential binding bug#195
ihsankahveci wants to merge 1 commit intokc-pit-2026-testfrom
fix/non-family-network-binding-bug

Conversation

@ihsankahveci
Copy link
Copy Markdown
Collaborator

📄 Description

The non_family_network paneldynamic element had its bindings.panelCount set to "non_family_network" — its own name. This created a two-way binding conflict where SurveyJS's numeric panel count overwrote the array of person objects, corrupting 28 survey records with a bare number (1–7) instead of the expected array.

Fix: Break the self-referential binding by introducing a hidden intermediary variable and renaming fields to clearly separate concerns:

  • non_family_network_sizenetwork_size_agg (self-reported count, untouched)
  • New network_size_list (hidden expression, seeded from network_size_agg, updated by panel add/remove)
  • non_family_networknetwork_list (paneldynamic, stores array of person objects only)
  • panelCount now binds to network_size_list instead of self-referencing

✅ Checklist

  • Tests added/updated where needed
  • Docs added/updated if applicable
  • I have linked the issue this PR closes (if any)

🔗 Related Issues

Resolves #194

💡 Type of change

Type Checked?
🐞 Bug fix [x]
✨ New feature [ ]
📝 Documentation [ ]
♻️ Refactor [ ]
🛠️ Build/CI [ ]
Other (explain) [ ]

🧪 How to test

  1. Run npm run dev in client/
  2. Navigate to the Network Module in a survey
  3. Enter a number (e.g. 3) for the network size question
  4. Confirm 3 tabs appear on the next page
  5. Fill in person details, navigate back and forth between pages
  6. Complete the survey
  7. Check MongoDB — network_list should be an array of 3 objects, network_size_agg should be the original number

📝 Notes to reviewers

Breaking change for existing data: Renaming these fields means new surveys will use network_size_agg, network_size_list, and network_list. Existing records in MongoDB still have non_family_network_size and non_family_network. Any downstream analysis or data export code will need to account for both old and new field names.

…k array data

Break the two-way binding conflict where non_family_network's panelCount
bound to itself, causing the numeric count to overwrite the person-object
array in 28 survey records.

- Rename non_family_network_size → network_size_agg
- Rename non_family_network → network_list
- Add hidden network_size_list expression as binding intermediary
- panelCount now binds to network_size_list instead of self-referencing

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a SurveyJS paneldynamic configuration bug where a self-referential bindings.panelCount overwrote the panel’s array data, by renaming the affected fields and introducing an intermediary variable intended to separate “count” from “list”.

Changes:

  • Renamed the network-size question field (non_family_network_sizenetwork_size_agg).
  • Renamed the paneldynamic field (non_family_networknetwork_list) and changed panelCount binding to a new variable (network_size_list).
  • Added a hidden “bridge” element intended to seed network_size_list from network_size_agg.

Comment on lines +298 to +309
{
"name": "network_size_bridge",
"title": "Network Module",
"elements": [
{
"type": "expression",
"name": "network_size_list",
"visible": false,
"expression": "{network_size_agg}"
}
]
},
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

network_size_bridge is added as a new page between network_questions_p1 and network_questions_p2, but it has no visible elements. This will insert an extra blank step in the survey flow. Consider moving network_size_list into an existing page (e.g., network_questions_p2) as a hidden element, or mark this page itself as not visible so it doesn’t appear in navigation.

Copilot uses AI. Check for mistakes.
Comment on lines +303 to +306
"type": "expression",
"name": "network_size_list",
"visible": false,
"expression": "{network_size_agg}"
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

network_size_list is implemented as an expression question (expression: "{network_size_agg}"). Expression questions continuously recompute their value from the expression, which can overwrite updates coming from the paneldynamic bindings.panelCount when panels are added/removed. To make this a true “seed then mutate” bridge, use a value that is only initialized from network_size_agg (e.g., a hidden question with a defaultValue/defaultValueExpression) rather than a continuously calculated expression.

Suggested change
"type": "expression",
"name": "network_size_list",
"visible": false,
"expression": "{network_size_agg}"
"type": "text",
"name": "network_size_list",
"visible": false,
"readOnly": true,
"defaultValueExpression": "{network_size_agg}"

Copilot uses AI. Check for mistakes.
"name": "non_family_network",
"title": "For those {non_family_network_size} people, please fill in as much of the following information as you are able:\n",
"name": "network_list",
"title": "For those {network_size_agg} people, please fill in as much of the following information as you are able:\n",
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The panel title interpolates {network_size_agg}, but the actual panel count is bound to network_size_list. If the interviewer adds/removes panels, the title can become inaccurate. Consider referencing the bound count variable (or another value that tracks the current panel count) so the UI stays consistent with the data being collected.

Suggested change
"title": "For those {network_size_agg} people, please fill in as much of the following information as you are able:\n",
"title": "For those {network_size_list} people, please fill in as much of the following information as you are able:\n",

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants