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

Boolean Select from Material UI theme can never be set to Yes/true #2326

Closed
3 tasks done
davidnyman-caci opened this issue Apr 7, 2021 · 1 comment
Closed
3 tasks done
Labels
bug material-ui material-ui related theme issue

Comments

@davidnyman-caci
Copy link

davidnyman-caci commented Apr 7, 2021

Prerequisites

Description

When using the Material UI theme, the select drop down will always display a value of "No", all change events show the formData has a value of false for the field, regardless of what was selected. This appears to be an issue with the @rjsf/material-ui library, the provided example works as expected when using the default theme.

This seems to be caused by https://github.com/rjsf-team/react-jsonschema-form/blob/master/packages/material-ui/src/SelectWidget/SelectWidget.tsx#L25 where it fails a strict equality check of the value; the function is given a boolean true or false, which is never equal to "true". It appears the same problem was encountered by https://github.com/rjsf-team/react-jsonschema-form/blob/master/packages/semantic-ui/src/SelectWidget/SelectWidget.js#L44

Steps to Reproduce

  1. Go to the playground https://rjsf-team.github.io/react-jsonschema-form/
  2. Change the theme from default to material-ui
  3. Paste the following text into the JSONSchema field
{
  "type": "object",
  "properties": {
    "myStuckBoolean": {
      "type": "boolean",
      "title": "myStuckBoolean"
    }
  }
}
  1. Paste the following text into the UISchema field
{
  "myStuckBoolean": {
    "ui:widget": "select"
  }
}
  1. Paste the following text into the formData field
{
  "myStuckBoolean": true
}
  1. Select "Yes" on the generated form

Expected behavior

Selecting Yes causes it to be selected/reselected

Actual behavior

No is always selected/reselected regardless of choice

Version

"@rjsf/core@2.4.2",
"@rjsf/material-ui@2.4.2",

ArnoSaine added a commit to Visma-Consulting/formula that referenced this issue Sep 6, 2021
@jacqueswho jacqueswho added material-ui material-ui related theme issue bug labels Feb 24, 2022
@heath-freenome
Copy link
Member

This was fixed in the v5 beta

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug material-ui material-ui related theme issue
Projects
None yet
Development

No branches or pull requests

3 participants