bhch / django-jsonform

A better, user-friendly JSON editing form field for Django admin. Also supports Postgres ArrayField.
https://django-jsonform.rtfd.io
BSD 3-Clause "New" or "Revised" License
352 stars 34 forks source link

Bug: Nullable Subschema (anyOf with `null`) causes UI exception #167

Open gersmann opened 6 months ago

gersmann commented 6 months ago

A schema with this top level defiinition: 'anyOf': [{'$ref': '#/$defs/TestModel'}, {'type': 'null'}]

Leads to an UI error, whent he null option is selected.

Initial:

image

After selecting null option:

image

The widget should probably replace / reinitialize the form data, if another anyOf option is selected.

Console:

Error: No matching subschema found in 'anyOf' for data '' (type: string)
    T http://localhost:8000/static/django_jsonform/react-json-form.js:1
    <anonymous> http://localhost:8000/static/django_jsonform/react-json-form.js:1
    render http://localhost:8000/static/django_jsonform/react-json-form.js:1
    React 23
[add:12714:25](http://localhost:8000/admin/returns/returnregistration/add/?account=1)
    overrideMethod http://localhost:8000/admin/returns/returnregistration/add/?account=1:12714
    React 25