-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
Prerequisites
- I have searched the existing issues
- I understand that providing a SSCCE example is tremendously useful to the maintainers.
- I have read the documentation
- Ideally, I'm providing a sample JSFiddle, Codesandbox.io or preferably a shared playground link demonstrating the issue.
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:
- Go to Sandbox: https://codesandbox.io/p/sandbox/new-sky-82rvdl
- Click "Set Extra Error"
- Click "Clear Extra Error"
Observe: Extra error remains displayed.
Expected: Extra error disappears.
Also:
- Click "Set Extra Error"
- Click "Clear Extra Error"
- 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.