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

Error not propagated when raising errors from a custom widget or field #4382

Closed
4 tasks done
guilhermecastros opened this issue Nov 15, 2024 · 2 comments · Fixed by #4395
Closed
4 tasks done

Error not propagated when raising errors from a custom widget or field #4382

guilhermecastros opened this issue Nov 15, 2024 · 2 comments · Fixed by #4395
Labels

Comments

@guilhermecastros
Copy link
Contributor

guilhermecastros commented Nov 15, 2024

Prerequisites

What theme are you using?

core

Version

5.x

Current Behavior

Error messages are not being propagated correctly for json object schemas.

For instance I have these two schemas, when I raise a custom error with schema2 it works nice as expected & described on the documentation. But when I do the same, but for schema which has a type object it doesn't work.

export const schema: RJSFSchema = {
  properties: {
    Test: {
      type: "number",
      title: "Test 1",
    },
    Test2: {
      type: "number",
      title: "Test 2",
    },
  },
  type: "object",
};
export const schema2: RJSFSchema = {
  type: "string",
  default: "hello",
};

I have created the following playground that allows you to play & to check the current behavior ⬇️

https://codesandbox.io/p/sandbox/rjsf-custom-error-ql66mh?workspaceId=7d9d1079-911b-4954-9a3d-7c3de5279f0c

image

image

Expected Behavior

Custom errors should show regardless of the schema used, which means it should show on both described scenarios.

Steps To Reproduce

  1. Open playground.
  2. You will see that I am rendering two schemas.
  3. Type something on each field
  4. You will see that for the schema of type object, no error is shown.

Environment

- OS:
- Node:
- npm:

Anything else?

No response

@guilhermecastros guilhermecastros added bug needs triage Initial label given, to be assigned correct labels and assigned labels Nov 15, 2024
@guilhermecastros
Copy link
Contributor Author

I believe this issue is related to #4188. Maybe @abdalla-rko knows more about this?

@heath-freenome heath-freenome removed the needs triage Initial label given, to be assigned correct labels and assigned label Nov 22, 2024
@heath-freenome
Copy link
Member

@guilhermecastros Thanks for finding this. We have a bug in our NumberField which I will be fixing soon

heath-freenome added a commit to heath-freenome/react-jsonschema-form that referenced this issue Nov 22, 2024
Fixes rjsf-team#4382

- Updated `NumberField`'s `handleChange` callback to pass through the `errorSchema` and `id`
- Updated the peerDependencies for the packages to be `5.23.x`
- Updated `CHANGELOG.md` accordingly
heath-freenome added a commit that referenced this issue Nov 22, 2024
…nge (#4395)

Fixes #4382

- Updated `NumberField`'s `handleChange` callback to pass through the `errorSchema` and `id`
- Updated the peerDependencies for the packages to be `5.23.x`
- Updated `CHANGELOG.md` accordingly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants