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.18k stars 808 forks source link

Single-Select Matrix ignores `hideIfRowsEmpty: true` if a `visibleIf` expression evaluates to `true` #8495

Closed phuongvannguyen closed 3 months ago

phuongvannguyen commented 3 months 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

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
}
]
}
]
}

340255877-555a6f0e-4f7a-4d46-8cd9-6e9b80ade8aa

JaneSjs commented 3 months ago

Hello, Thank you for sharing a demo. In your survey configuration, Q3 has Row 2 which always appears regardless of confitional logic.

Would you please elaborate on your end goal?

JaneSjs commented 3 months ago

To our developers: @andrewtelnov, when a matrix defines two visibility conditions (visibleIf and hideIfRowsEmpty: true), a matrix appears even though its rows are invisible. Please consider this demo: View Plunker.

{
 "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'"
      },
      {
       "value": "Row 2",
       "visibleIf": "{question2} = 'abc'"
      }
     ],
     "hideIfRowsEmpty": true
    }
   ]
  }
 ]
}

image

Expected behavior: a matrix doesn't appear unless a row becomes visible.

phuongvannguyen commented 3 months ago

hi Jane, my expectation is Q3 will be shown only if when Q1 = Yes and it has rows

On Tue, Jul 2, 2024 at 4:57 PM Jane @.***> wrote:

Hello, Thank you for sharing a demo. In your survey configuration, Q3 has Row 2 which always appears regardless of confitional logic.

Would you please elaborate on your end goal?

— Reply to this email directly, view it on GitHub https://github.com/surveyjs/survey-library/issues/8495#issuecomment-2202604032, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKQC5Q3KN5YJAIZMDH67LDDZKJ2PZAVCNFSM6AAAAABKGV3Q66VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMBSGYYDIMBTGI . You are receiving this because you authored the thread.Message ID: @.***>

-- This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you are not the named addressee and have received this email in error please notify the sender and delete it immediately. Unauthorized use,  dissemination, or distribution of this email is strictly prohibited.