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

5.2.1 has broken file uploads (schema attached) #3504

Closed
4 tasks done
billycrid opened this issue Mar 15, 2023 · 4 comments · Fixed by #3547
Closed
4 tasks done

5.2.1 has broken file uploads (schema attached) #3504

billycrid opened this issue Mar 15, 2023 · 4 comments · Fixed by #3547

Comments

@billycrid
Copy link

billycrid commented Mar 15, 2023

Prerequisites

What theme are you using?

core

Version

5.2.1

Current Behavior

Currently with 5.2.1, when trying to upload a file with default bootstrap configuration: after attaching a .csv file (with uiSchema specifying only .csv format allowed). after clicking Submit the field is highlighted with 'field is required'

Expected Behavior

File should be attached to the form as previously was in 5.2.0

Steps To Reproduce

  1. checkout 5.2.1 version
  2. use inputSchema:
{
  "properties": {
    "uploadedFile": {
      "items": {
        "format": "data-url",
        "type": "string"
      },
      "title": "some file",
      "type": "array"
    }
  },
  "required": [
    "uploadedFile"
  ],
  "type": "object"
}
  1. use uiSchema:
{
  "uploadedFile": {
    "ui:options": {
      "accept": [
        ".csv"
      ]
    }
  }
}
  1. try to submit the form after uploading a .csv file
  2. error will show as if field is not populated
  3. then switch to version 5.2.0 of the lib and repeat steps and the form will submit correctly

can be recreated in this codesandbox: https://codesandbox.io/embed/condescending-raman-fylt3x?fontsize=14&hidenavigation=1&theme=dark

Environment

- OS: OSX latest
- Node: 16.17.1
- npm: 8.15.0

Anything else?

No response

@billycrid billycrid added bug needs triage Initial label given, to be assigned correct labels and assigned labels Mar 15, 2023
@heath-freenome
Copy link
Member

@billycrid so I just put your example into the playground and could not reproduce the issue. Do you have any customizations?

@heath-freenome heath-freenome added awaiting response cannot-reproduce and removed needs triage Initial label given, to be assigned correct labels and assigned labels Mar 16, 2023
@billycrid
Copy link
Author

billycrid commented Mar 24, 2023

@heath-freenome please see the defect recreated in a codesandbox URL: https://codesandbox.io/embed/condescending-raman-fylt3x?fontsize=14&hidenavigation=1&theme=dark

hopefully this helps to recreate.

Also note, if you change the version down to 5.2.0 this upload file works as expected.

@heath-freenome
Copy link
Member

@billycrid What specifically isn't working? I managed to upload a csv file just fine using your code sandbox. There was an issue with submitting complaining about missing required field, but adding the noHtml5Validate={true} took care of that. Can you screenshot or show a playback of this not working?

@billycrid
Copy link
Author

billycrid commented Mar 26, 2023

@heath-freenome yeah this is exactly the issue, because the field is validating as not being complete, we are getting the HTML5 error suddenly which is blocking form submission even though all required fields are actually populated. Disabling Html5 Validation should not be an acceptable 'fix' for this as we still require HTML5 validation on all fields in the form. Is there anything else we can do to get around this or any fix thats possible to keep HTML5 validation but form field actually be filled out?

heath-freenome added a commit to heath-freenome/react-jsonschema-form that referenced this issue Mar 27, 2023
Fixes rjsf-team#3504 by setting the `required` prop to false once a file is chosen
Also enhanced the `ObjectFieldTemplate` to be able to receive the `errorSchema`
- In `@rjsf/utils`, added `errorSchema` to the `ObjectFieldTemplateProps`
- In `@rjsf/core`, updated `ObjectField` to pass the `errorSchema` to the `ObjectFieldTemplate`
  - Also updated `FileWidget` to pass false as the `required` prop once a file has been chosen
heath-freenome added a commit that referenced this issue Mar 27, 2023
…3547)

Fixes #3504 by setting the `required` prop to false once a file is chosen
Also enhanced the `ObjectFieldTemplate` to be able to receive the `errorSchema`
- In `@rjsf/utils`, added `errorSchema` to the `ObjectFieldTemplateProps`
- In `@rjsf/core`, updated `ObjectField` to pass the `errorSchema` to the `ObjectFieldTemplate`
  - Also updated `FileWidget` to pass false as the `required` prop once a file has been chosen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants