Skip to content

ValidateAndHide only partially working for react material table cell #2398

@0mpurdy

Description

@0mpurdy

Describe the bug

Validation mode 'ValidateAndHide' does not hide error messages in array object cells (rendered by the React MaterialTableControl)

Expected behavior

The error should be hidden

Steps to reproduce the issue

  1. Create a schema with an array of objects, where the object has required properties

    e.g.

    {
        "type": "object",
        "properties": {
            "someArray": {
                "type": "array",
                "items": {
                    "type": "object",
                    "properties": {
                        "name": {"type": "string"},
                        "age": {"type": "number"},
                    },
                    "required": ["name"],
                },
            },
        },
    }
  2. Render the schema with the react material renderers and validation mode 'ValidateAndHide'

    <JsonForms
      {...otherProps}
      validationMode={'ValidateAndHide'}
    />

Screenshots

validationMode screenshot
NoValidation NoValidation shows grey box input box and no red error message
ValidateAndHide ValidateAndHide shows grey input box with red error message
ValidateAndShow ValidateAndShow shows red input box with red error message

Which Version of JSON Forms are you using?

v3.4.1

Package

Core, React Material Renderers

Additional context

I'm not very familiar with the codebase so apologies if this is a red herring, but it looks like the control code which correctly hides the error uses getErrorAt from src/store/jsonFormsCore and this respects validation mode.

Whereas the cell error label instead uses errorsAt which comes from src/util/errors.

There may be a good reason for that of course which I don't understand - but I'd expect cells and controls both to respect that validationMode property

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions