surveyjs / survey-library

Free JavaScript form builder library with integration for React, Angular, Vue, jQuery, and Knockout.
https://surveyjs.io/form-library
MIT License
4k stars 780 forks source link

Matrix question configured with visible if condition and 'Hide the question if it has no rows"= True #8393

Closed phuongvannguyen closed 1 week ago

phuongvannguyen commented 2 weeks ago

Are you requesting a feature, reporting a bug or asking a question?

I'm requesting a feature

What is the current behavior?

When I set a matrix Q3 with 'Hide the question if it has no rows"= True, row visible if Q2 = 'abc' and Q3 is visible if Q1 = yes then when I choose Q1 = No and input 'abc' for Q2--> Q3 is shown despite of the condition Q3 is visible if Q1 = yes.

What is the expected behavior?

The expectation in this case is Q3 is not shown. Q3 is shown only if when Q1 = Yes and it has rows

How would you reproduce the current behavior (if this is a bug)?

Provide the test code and the tested page URL (if applicable)

Tested page URL:

Test code

your_code_here

Specify your

JaneSjs commented 1 week ago

Hello, I followed your explanation and created the following form:

{
 "pages": [
  {
   "name": "page1",
   "elements": [
    {
     "type": "boolean",
     "name": "Q1"
    },
    {
     "type": "dropdown",
     "name": "Q2",
     "choices": [
      {
       "value": "abc",
       "text": "ABC"
      },
      "Item 2",
      "Item 3"
     ]
    },
    {
     "type": "matrixdropdown",
     "name": "Q3",
     "visibleIf": "{Q1} = true",
     "columns": [
      {
       "name": "Column 1"
      },
      {
       "name": "Column 2"
      },
      {
       "name": "Column 3"
      }
     ],
     "choices": [
      1,
      2,
      3,
      4,
      5
     ],
     "rows": [
      "Row 1",
      "Row 2"
     ],
     "hideIfRowsEmpty": true
    }
   ]
  }
 ]
}

image The logic works correctly and a matrix appears only when setting Q1 to Yes. I tested this survey in our online demo.

Please clarify how to reproduce the issue.

Thanks

phuongvannguyen commented 1 week ago

Hi,

Below is my test on online demo { "logoPosition": "right", "pages": [ { "name": "page1", "elements": [ { "type": "boolean", "name": "question1", "title": "Q1" }, { "type": "text", "name": "question2", "title": "Q2" }, { "type": "matrix", "name": "question3", "visibleIf": "{question1} = true", "title": "Q3", "columns": [ "Column 1", "Column 2", "Column 3" ], "rows": [ { "value": "Row 1", "visibleIf": "{question2} = 'abc'" }, "Row 2" ], "hideIfRowsEmpty": true } ] } ] } image