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

OneOf with antd theme render as multiple selector #3595

Closed
4 tasks done
Plokkke opened this issue Apr 11, 2023 · 1 comment · Fixed by #3597
Closed
4 tasks done

OneOf with antd theme render as multiple selector #3595

Plokkke opened this issue Apr 11, 2023 · 1 comment · Fixed by #3597
Labels
bug needs triage Initial label given, to be assigned correct labels and assigned

Comments

@Plokkke
Copy link
Contributor

Plokkke commented Apr 11, 2023

Prerequisites

What theme are you using?

antd

Version

5.x

Current Behavior

When defining a root level oneOf property with antd them. rjsf render a broken multiple select.

bug is available in official playground using this schema

{
  "title": "A registration form",
  "description": "A simple form example.",
  "type": "object",
  "oneOf": [
    {
      "title": "Contact",
      "properties": {
        "telephone": {
          "type": "string",
          "title": "Telephone",
          "minLength": 10
        }
      }
    },
    {
      "title": "Identity",
      "properties": {
        "firstName": {
          "type": "string",
          "title": "First name",
          "default": "Chuck"
        },
        "lastName": {
          "type": "string",
          "title": "Last name"
        }
      }
    },
    {
      "title": "Address",
      "properties": {
        "firstName": {
          "type": "string",
          "title": "Street"
        },
        "lastName": {
          "type": "string",
          "title": "City"
        }
      }
    }
  ]
}

Expected Behavior

The rendered component should be a single selector or a multiple selector UI with the limitation of only one selected item

Steps To Reproduce

  1. Go to official playground
  2. Copy provided schema or select oneOf in predefined section
  3. Select default theme
  4. Try to open selector and switch between options (Working)
  5. Select antd theme
  6. Try to open selector and switch between options (Broken)

Environment

- OS: MacOS
- Navigator: Chrome 112
- Node: irelevant
- npm: irelevant

Anything else?

No response

@Plokkke Plokkke added bug needs triage Initial label given, to be assigned correct labels and assigned labels Apr 11, 2023
@Plokkke
Copy link
Contributor Author

Plokkke commented Apr 12, 2023

In file packages/antd/src/widgets/SelectWidget/index.tsx on line 86, the following line can be found:
mode={typeof multiple !== 'undefined' ? 'multiple' : undefined}
considering false as a truthy value for multiple display.

I suggest the following replacement:
mode={multiple ? 'multiple' : undefined}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug needs triage Initial label given, to be assigned correct labels and assigned
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant