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
307 stars 31 forks source link

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

Open gersmann opened 1 month ago

gersmann commented 1 month 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