Skip to content

Changes to extraErrors prop are not reflected in Form state. #4408

@studiosciences

Description

@studiosciences

Prerequisites

What theme are you using?

core

Version

5.x

Current Behavior

When liveValidation is enabled, the extraErrors prop can only add errors, not clear or change them. It only clears previous extraErrors from state onSubmit().

Expected Behavior

Changing extraErrors prop immediately updates the UI.

This is necessary for cases such as:

  • live validation of unique key requirements, such as username availability.
  • RJSF is a part of larger form (onSubmit is not called within RJSF's Form component).

Steps To Reproduce

Repo:

  1. Go to Sandbox: https://codesandbox.io/p/sandbox/new-sky-82rvdl
  2. Click "Set Extra Error"
  3. Click "Clear Extra Error"

Observe: Extra error remains displayed.
Expected: Extra error disappears.

Also:

  1. Click "Set Extra Error"
  2. Click "Clear Extra Error"
  3. Repeat

Observe: Extra error is duplicated in each cycle
Expected: Extra error disappears.

Environment

No response

Anything else?

When deriving state from props, extraErrors is merged into the existing state that already includes the extra error.
https://github.com/rjsf-team/react-jsonschema-form/blob/main/packages/core/src/components/Form.tsx#L462-L466

I'm open to making a PR, but I'm not clear on what other errors RJSF may have set in the errorSchema (required fields?) or how to separate the two.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions