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.12k stars 802 forks source link

Checkboxes with the Other option and Comment box - The survey.getPlainData returns a displayValue which contains a comment value instead of the other option value #7950

Closed JaneSjs closed 6 months ago

JaneSjs commented 6 months ago

T17239 - Bug when using comment box with multiselect element https://surveyjs.answerdesk.io/internal/ticket/details/T17239


View Demo The following survey:

{
 "pages": [
  {
   "name": "Seite1",
   "elements": [
    {
     "type": "checkbox",
     "name": "Frage1",
     "title": "Q1",
     "showCommentArea": true,
     "commentText": "Comment",
     "choices": [
      "Item 1",
      "Item 2",
      "Item 3"
     ],
     "showOtherItem": true
    }
   ]
  }
 ],
 "widthMode": "responsive"
}

image

Produces the following plain data:

[
  {
    "name": "Frage1",
    "title": "Q1",
    "value": [
      "Item 1",
      "Item 2",
      "Other Value"
    ],
    "displayValue": "Item 1, Item 2, Comment is Here",
    "isNode": true,
    "data": [
      {
        "name": 0,
        "isComment": true,
        "title": "Comment",
        "value": "-Comment",
        "displayValue": "Comment is Here",
        "isNode": false
      },
      {
        "name": 0,
        "title": "Choice",
        "value": "Item 1",
        "displayValue": "Item 1",
        "isNode": false
      },
      {
        "name": 1,
        "title": "Choice",
        "value": "Item 2",
        "displayValue": "Item 2",
        "isNode": false
      },
      {
        "name": 2,
        "title": "Choice",
        "value": "Other Value",
        "displayValue": "Other Value",
        "isNode": false
      }
    ]
  }
]

The issue is that the displayValue contains a comment text instead of the Other option text: "displayValue": "Item 1, Item 2, Comment is Here".

tsv2013 commented 6 months ago

Fixed with the https://github.com/surveyjs/survey-analytics/issues/403 via the PR