Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If a field is hidden, it should NOT be validated #825

Closed
barmac opened this issue Sep 28, 2023 · 3 comments
Closed

If a field is hidden, it should NOT be validated #825

barmac opened this issue Sep 28, 2023 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@barmac
Copy link
Member

barmac commented Sep 28, 2023

Describe the Bug

Hidden fields are validated even though there is no way to change their values.

Steps to Reproduce

  1. Open this form:
{
  "components": [
    {
      "label": "Checkbox",
      "type": "checkbox",
      "layout": {
        "row": "Row_0ifu9f7",
        "columns": null
      },
      "id": "Field_0r8ir96",
      "key": "checkbox_4u82gk"
    },
    {
      "label": "Number",
      "type": "number",
      "layout": {
        "row": "Row_0ifu9f7",
        "columns": null
      },
      "id": "Field_17uk1c9",
      "key": "number_o4f027",
      "conditional": {
        "hide": "=checkbox_4u82gk"
      },
      "validate": {
        "required": true
      }
    },
    {
      "action": "reset",
      "label": "Reset",
      "type": "button",
      "id": "Field_1jcm8tv",
      "layout": {
        "row": "Row_0ifu9f7"
      }
    },
    {
      "action": "submit",
      "label": "Button",
      "type": "button",
      "layout": {
        "row": "Row_15idciq",
        "columns": null
      },
      "id": "Field_0bqqn6m"
    }
  ],
  "type": "default",
  "id": "Form_0k71hbi",
  "exporter": {},
  "schemaVersion": 11
}
  1. Tick the checkbox
  2. Submit and read the errors
  3. Field_17uk1c9 appears in the errors, even though it's hidden.

Expected Behavior

Field should not be validated if it's hidden.

Environment

  • Host (Browser/Node version), if applicable: [e.g. MS Edge 18, Chrome 69, Node 10 LTS]
  • OS: [e.g. Windows 7]
  • Library version: [e.g. 2.0.0]

Reported via forums: https://forum.camunda.io/t/required-validation-on-hidden-inputs/47782

@barmac barmac added the bug Something isn't working label Sep 28, 2023
@pinussilvestrus
Copy link
Contributor

pinussilvestrus commented Sep 28, 2023

Thanks for opening! I used your form and tried to reproduce it with the steps you provided. What is interesting is that when using other keys, the behavior works as expected (no errors shown)

Image

In this line we explicitly filter for hidden fields. Maybe there is something not working with the provided key (lower case + special chars)?

pinussilvestrus pushed a commit that referenced this issue Sep 28, 2023
@bpmn-io-tasks bpmn-io-tasks bot added the in progress Currently worked on label Sep 28, 2023
@pinussilvestrus
Copy link
Contributor

@pinussilvestrus
Copy link
Contributor

It seems like this._applyConditions only removes via the value path of the given field, but we reference errors via the ID, which might be the root cause here - and why my example above worked as I used the same key & id.

pinussilvestrus pushed a commit that referenced this issue Sep 28, 2023
@bpmn-io-tasks bpmn-io-tasks bot added needs review Review pending and removed in progress Currently worked on labels Sep 28, 2023
pinussilvestrus pushed a commit that referenced this issue Oct 5, 2023
pinussilvestrus pushed a commit that referenced this issue Oct 5, 2023
@bpmn-io-tasks bpmn-io-tasks bot removed the needs review Review pending label Oct 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

2 participants