Skip to content

Can't use default object with enum object (Radio list) #4635

@rmaury

Description

@rmaury

Prerequisites

What theme are you using?

core

Version

5.24.x

Current Behavior

I'm currently having an issue after updating my version of react-json-schema.
Before that, I could create a radio element with a list of object in enum, and a default object to initialize.

Example :

"example": {
      "title": "Radio with object",
      "default": {
        "label": "First element",
        "value": "one"
      },
      "enum": [
          {
          "label": "First element",
          "value": "one"
        },
        {
          "label": "Second element",
          "value": "two"
        },
        {
          "label": "Third element",
          "value": "three"
        }
      ],
      "minItems": 1,
      "maxItems": 1,
    }

Since I've updated to 5.24.x, if the default value is an object, I can't select other option in the rendered Radio Element.
I have to delete the default from jsonSchema to make it works.

Do you have any idea to get a default value with a list of object in enum ?
Or is that a bad practice and this is something you don't allow anymore ?

Expected Behavior

Select other item in rendered view when I've set a default value with an object

Steps To Reproduce

You can test it in :

https://rjsf-team.github.io/react-jsonschema-form/
-> Enumerated Objects
-> just add this in properties -> locationRadio
"default": { "name": "New York", "lat": 40, "lon": 74 }

And try to select Amsterdam on the rendered part.
You can't

Environment

- OS: Ubuntu
- Node: 22
- npm:

Anything else?

Image
(can't select Amsterdam on right part after adding a default value)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions